Pagini recente » Cod sursa (job #1875530) | Cod sursa (job #297783) | Cod sursa (job #2459857) | Cod sursa (job #2315893) | Cod sursa (job #593434)
Cod sursa(job #593434)
#define _CRT_SECURE_NO_DEPRECATE
#include <stdio.h>
#include <stdlib.h>
int zero(int x)
{
int i=0,j=5,q=1;
while (q != 0)
{
q = x / j;
i += q;
j*=5;
}
return i;
}
int main()
{
FILE * f = fopen("fact.in","r");
int p,n;
fscanf(f,"%d",&p);
fclose(f);
n=5*p;
while (zero(n)>p) n-=5;
while (zero(n)<p) n+=5;
if (n == 0) n++;
f = fopen("fact.out","w");
fprintf(f,"%d",n);
fclose(f);
return 0;
}