Bhavna Chaudhri

Bhavna Chaudhri

  • 1.5k
  • 531
  • 6.4k

calculate factorial error.

Dec 1 2020 8:19 AM
what is wrong with my factorial code , it gives 0 output?
  1. public static void Main()    
  2. {  
  3.     Console.WriteLine(Factorial(100));    
  4.     Console.ReadLine();    
  5. }  
  6.     
  7. public static int Factorial(int num)    
  8. {    
  9.     int fact = 1;    
  10.     for (int i = num; i > 1; i--)    
  11.     {    
  12.         fact = fact * i;    
  13.     }    
  14.     return fact;    
  15. } 

Answers (2)