Advertisement
geniusvil

Method-10

Dec 17th, 2013
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Numerics;
  7.  
  8. namespace _10.FactorialFrom1To100ForAll
  9. {
  10. class Program
  11. {
  12. /*Write a program to calculate n! for
  13. * each n in the range [1..100].
  14. * Hint: Implement first a method that
  15. * multiplies a number represented as array
  16. * of digits by given integer number. */
  17.  
  18. static BigInteger Factorial(int n)
  19. {
  20. if (n == 0)
  21. {
  22. return 1;
  23. }
  24. else
  25. {
  26. return n * Factorial(n - 1);
  27. }
  28. }
  29.  
  30. static void Main(string[] args)
  31. {
  32. int[] arrayNumbers = new int[100];
  33. for (int i = 0; i < 100; i++)
  34. {
  35. arrayNumbers[i] = i + 1;
  36. Console.WriteLine(Factorial(arrayNumbers[i]));
  37. }
  38. }
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement