The following program works for small numbers such 5, 10, 11 etc but as soon as i enter a large number such as 60, the no of trailing zeroes in its factorial shows zero. Can anyone help?
#include<iostream.h>
#include<math.h>
#include<conio.h>
unsigned long int factorial(unsigned long int);
int main()
{
unsigned long int t,n;
unsigned int count,i;
cin>>t;
unsigned long int a[10];
for(i=0;i<t;++i)
{
cin>>n;
a[i]=factorial(n);
}
for(i=0;i<t;++i)
{
count=0;
while(a[i]>0)
{
if(a[i]%10==0)
count++;
a[i]=a[i]/10;
}
cout<<count<<’\n’;
}
getch();
return(0);
}
unsigned long int factorial(unsigned long int x)
{
unsigned int i=1;
unsigned long int f=1;
while(i<=x)
{
f=f*i;
i++;
}
return(f);
}