ellapt

T.9.10.nFactorialMethod

Jan 20th, 2013
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. using System;
  2. using System.Numerics;
  3.  
  4. class NfactorialMethod
  5. {
  6. static BigInteger Factorial(int n)
  7. {
  8. BigInteger nFactorial = 1;
  9.  
  10. for (int i = 1; i <= n; i++)
  11. {
  12. nFactorial*=i;
  13. }
  14. return nFactorial;
  15. }
  16.  
  17. static void Main()
  18. {
  19. int n=100;
  20. // ******************** The rezult of 100! *********************************
  21. BigInteger nf = Factorial(n);
  22.  
  23. Console.WriteLine("{0}! = {1:N}", n, nf);
  24. }
  25. }
  26.  
  27.  
  28. /* static int NfactTrailZeros(int n)
  29. {
  30. int primeDiv5 = 5;
  31. int maxDivider = 5;
  32. int count = 0;
  33. while (maxDivider <= n)
  34. {
  35. count += n / maxDivider;
  36. maxDivider *= primeDiv5;
  37. }
  38. return count;
  39. }
  40. */
Advertisement
Add Comment
Please, Sign In to add comment