Cod sursa(job #600126)
Utilizator | Data | 30 iunie 2011 16:49:14 | |
---|---|---|---|
Problema | Factorial | Scor | 15 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.35 kb |
#include <fstream.h>
long n,p,p1,tmp,s;
long fact(long q)
{
long x=1;
s=0;
while(x<=q)
{
x=x*5;
tmp=q/x;
s=s+tmp;
}
return s;
}
int main()
{
ifstream f("fact.in");
ofstream g("fact.out");
f>>p;n=1;
while(p1!=p)
{
n++;
p1=fact(n);
}
g<<n;
f.close();
g.close();
return 0;
}