Cod sursa(job #397691)
Utilizator | Data | 17 februarie 2010 12:41:33 | |
---|---|---|---|
Problema | Factorial | Scor | 5 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.25 kb |
#include<stdio.h>
#include <math.h>
int main()
{
long p, n, k = 2, c= 25;
freopen("fact.in","r",stdin);
freopen("fact.out","w",stdout);
scanf("%ld", &p);
n = 5*p;
while ( n / c >=1)
{
n= n - 5 *(n/c)* (k-1);
k++;
c = c*5;
}
printf("%ld",n);
}