JulianJulianov

03.ObjectAndClasses-Big Factorial

Mar 5th, 2020
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.16 KB | None | 0 0
  1. 03.ObjectAndClasses-Big Factorial
  2. You will receive N – a number in the range [01000]. Calculate the Factorial of N and print the result.
  3. Examples
  4. Input       Output
  5. 50          30414093201713378043612608166064768844377641568960512000000000000
  6. 125         18826771768889260997437677024916008575954036487149242588759823150835315633161359886688293288949592313364640544
  7.             5930057740630161919341380597818883457558547055524326375565007131770880000000000000000000000000000000
  8.        
  9. Hints
  10. Use the class BigInteger from the built-in .NET library System.Numerics.dll.
  11. 1.  Import the namespaceSystem.Numerics:
  12.  
  13. 2.  Use the type BigInteger to calculate the number factorial.
  14.  
  15. 3.  Loop from 2 to N and multiply every number with factorial.
  16.  
  17. using System;
  18. using System.Numerics;
  19.  
  20. namespace _03.BigFactorial
  21. {
  22.     class Program
  23.     {
  24.         static void Main(string[] args)
  25.         {
  26.             var number = int.Parse(Console.ReadLine());
  27.  
  28.             BigInteger bigInteger = 1;
  29.             for (int i = number; i > 0; i--)
  30.             {
  31.                 bigInteger *= i;
  32.             }
  33.             Console.WriteLine(bigInteger);
  34.         }
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment