Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Numerics;
- namespace _10.FactorialFrom1To100ForAll
- {
- class Program
- {
- /*Write a program to calculate n! for
- * each n in the range [1..100].
- * Hint: Implement first a method that
- * multiplies a number represented as array
- * of digits by given integer number. */
- static BigInteger Factorial(int n)
- {
- if (n == 0)
- {
- return 1;
- }
- else
- {
- return n * Factorial(n - 1);
- }
- }
- static void Main(string[] args)
- {
- int[] arrayNumbers = new int[100];
- for (int i = 0; i < 100; i++)
- {
- arrayNumbers[i] = i + 1;
- Console.WriteLine(Factorial(arrayNumbers[i]));
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement