http://www.codechef.com/viewsolution/1017061
when I give input as follows:
5
5
10
15
20
25
the output I get is:
1
2
3
4
0
import java.util.Scanner;
class Factorial
{
public static void main(String args[])
{
int i,n;
Scanner sc= new Scanner(System.in);
n=sc.nextInt();
long a[]=new long[n];
long cnt[]=new long[n];
for(i=0;i<n;i++)
{
a[i]=fact(sc.nextLong());
cnt[i]=0;
while(a[i]%10==0)
{
cnt[i]++;
a[i]=a[i]/10;
}
}
for(i=0;i<n;i++)
System.out.println(cnt[i]);
}
public static long fact(long n)
{
if (n == 0) return 1;
else
return n * fact(n-1);
}
}
when I give input as follows:
5
5
10
15
20
25
the output I get is:
1
2
3
4
0