Pagini recente » Cod sursa (job #1097217) | Cod sursa (job #3231672) | Cod sursa (job #225791) | Cod sursa (job #3291515) | Cod sursa (job #623028)
Cod sursa(job #623028)
#include <stdio.h>
#include <stdlib.h>
unsigned int count (unsigned int n)
{
unsigned int c=0;
while (n!=0)
{
c+=n/5;
n/=5;
}
return c;
}
int main()
{
unsigned int n,p,c;
freopen("fact.in","r",stdin);
freopen("fact.out","w",stdout);
scanf("%d",&p);
if (p!=0)
{
n = 4*p;
n +=(5-n%5); // round up to the nearest multiple of 5
c = count(n);
while (p>c)
{
n+=5;
c = count(n);
}
if (c==p)
printf("%d\n",n);
else
printf("-1\n");
}
else
printf("1\n");
return 0;
}