Pagini recente » Cod sursa (job #3212644) | Cod sursa (job #3268201) | Cod sursa (job #832282) | Cod sursa (job #2864767) | Cod sursa (job #238473)
Cod sursa(job #238473)
#include<stdio.h>
#include<math.h>
long long int P,i,aux,aprox,count;
long long int coef(long long int x)
{long int nr=0;
while(x%5==0)
{
x/=5;
nr++;
}
return nr;
}
int main()
{
FILE*in=fopen("fact.in","r");
FILE*out=fopen("fact.out","w");
fscanf(in,"%lld",&P);
aprox=5*P;
i=2;
count=P;
while(pow(5,i)<=aprox)
{
count+=aprox/pow(5,i);
i++;
}
while(count!=P)
{
aux=aprox;
aprox-=5;
count-=coef(aux);
}
fprintf(out,"%lld",aprox);
fcloseall();
return 0;
}