using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace can { class Program { static void Main(string[] args) { int k; Console.WriteLine("Enter a number whose factorial needs to be calculated: "); k = Convert.ToInt32(Console.ReadLine()); int[] numArr = new int[10000]; int total,rem=0,count,i; for(i=0;i<9999;i++) numArr[i]=0; numArr[9999]=1; for(count = 2 ; count <= k ; count++) { while(i>0) { total = numArr[i] * count + rem; rem=0; if(total>9) { numArr[i]=total%10; rem=total/10; } else { numArr[i]=total; } i--; } rem=0; total=0; i=9999; } Console.WriteLine("The factorial of " + k + " is "); for(i=0;i<10000;i++) { if(numArr[i]!=0 || count==1) { Console.Write(numArr[i]); count=1; } } Console.ReadLine(); } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)