Pagini recente » Cod sursa (job #512901) | kingoni | Cod sursa (job #434158) | Cod sursa (job #542011) | Cod sursa (job #2592663)
#include <iostream>
#include <cstdio>
#define nmax 1000000000
FILE * f = fopen("fact.in", "r");
FILE * g = fopen("fact.out", "w");
using namespace std;
int p;
int factorial (int h) {
int p = 1, h1, s = 0;
h1 = h;
while (p < h)
{
p = p * 5;
s = s + h1/p;
}
return s;
}
int main()
{ int ok = 0, q = 0, i;
fscanf(f,"%d",&p);
for(i=5;i<=nmax && ok == 0;i+=5)
{
if(factorial(i) == p)
{
q = i;
ok = 1;
}
}
fprintf(g,"%d",q);
fclose(f);
fclose(g);
return 0;
}