trailing zeros only works up to number 12
the following code works but only up to the number 12 after that the factorials are calculated wrong any help on how to fix this would be much appreciated thank you //only works for numbers less than 12 for some reason Console.WriteLine(""); Console.Write("Enter a number : "); string Num = Console.ReadLine(); int NUM; while(!int.TryParse(Num,out NUM) | NUM < 1 | NUM >12) { Console.WriteLine("You must enter a number greater than 0 and less than 13 : "); Num = Console.ReadLine(); } int fact=1; for (int a = NUM; a > 1; a--) { fact = fact * a; } string Fact = fact.ToString(); int x = Fact.Length; int y = 0; for (int a = x-1; a >=0; a--) { if (Fact[a].ToString().Contains("0")) { y = y + 1; } else { break; } } Console.WriteLine("{0}! is {1} and ends in {2} zeros",Num,Fact,y);