Pagini recente » Cod sursa (job #2454579) | Cod sursa (job #1444405) | Cod sursa (job #171957) | Cod sursa (job #1277169) | Cod sursa (job #218635)
Cod sursa(job #218635)
/*
* factorial.cpp
*
* Created on: Nov 2, 2008
* Author: stefan
*/
#include<stdio.h>
int main()
{
long int P, N, i;
freopen("fact.in", "r", stdin);
freopen("fact.out", "w", stdout);
scanf("%ld", &P);
if (P == 0)
{
printf("1");
return 0;
}
for (N = 5; P > 0; N += 5)
{
i = N;
while (i % 5 == 0)
{
--P;
i /= 5;
}
}
if (P)
printf("-1");
else
printf("%ld", N-5);
return 0;
}