Advertisement
Martichka

[C#] Methods/ Task 10 - FactorialN

Jan 23rd, 2013
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.74 KB | None | 0 0
  1. using System;
  2. using System.Numerics;
  3. class FactorialN
  4. {
  5.     static void MakeArray(int number)
  6.     {
  7.         int[] array = new int[number];
  8.         for (int i = 0; i < array.Length; i++)
  9.         {
  10.             array[i] = i + 1;
  11.         }
  12.        
  13.         BigInteger factorialN = CalculatesFactorial(array);
  14.         Console.WriteLine(factorialN);
  15.     }
  16.     static BigInteger CalculatesFactorial(int[] arr)
  17.     {
  18.         int index = 0;
  19.         BigInteger factorial = 1;
  20.         for (index = 0; index < arr.Length; index++)
  21.         {
  22.             factorial *= arr[index];
  23.         }
  24.         return factorial;
  25.     }
  26.     static void Main()
  27.     {
  28.         int n = int.Parse(Console.ReadLine());
  29.         MakeArray(n);
  30.        
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement