Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 03.ObjectAndClasses-Big Factorial
- You will receive N – a number in the range [0 – 1000]. Calculate the Factorial of N and print the result.
- Examples
- Input Output
- 50 30414093201713378043612608166064768844377641568960512000000000000
- 125 18826771768889260997437677024916008575954036487149242588759823150835315633161359886688293288949592313364640544
- 5930057740630161919341380597818883457558547055524326375565007131770880000000000000000000000000000000
- Hints
- Use the class BigInteger from the built-in .NET library System.Numerics.dll.
- 1. Import the namespace “System.Numerics”:
- 2. Use the type BigInteger to calculate the number factorial.
- 3. Loop from 2 to N and multiply every number with factorial.
- using System;
- using System.Numerics;
- namespace _03.BigFactorial
- {
- class Program
- {
- static void Main(string[] args)
- {
- var number = int.Parse(Console.ReadLine());
- BigInteger bigInteger = 1;
- for (int i = number; i > 0; i--)
- {
- bigInteger *= i;
- }
- Console.WriteLine(bigInteger);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment