Cod sursa(job #617325)
| Utilizator | Data | 14 octombrie 2011 16:40:34 | |
|---|---|---|---|
| Problema | Factorial | Scor | 25 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.61 kb |
#include <stdio.h>
int calc_five( int n )
{
int c=0;
while( n%5 ==0 )
{
c++;
n/=5;
}
return c;
}
int calc_n( int p )
{
int putere=0;
int aux=1, i=1;
if(p==0) return 1;
while( putere<p )
{
aux=5*i;
int c=calc_five(aux);
//printf("ceva");
i++;
putere=putere+c;
}
return aux;
}
int main()
{
int p;
FILE *f = fopen("fact.in", "r");
FILE *f2 = fopen("fact.out", "w");
fscanf(f, "%d", &p);
fprintf(f2, "%d", calc_n(p));
printf("%d ", calc_n(p));
return 0;
}
