Cod sursa(job #39604)
Utilizator | Data | 26 martie 2007 20:53:56 | |
---|---|---|---|
Problema | Factorial | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.46 kb |
// Problema factorial
#include <stdio.h>
int main()
{
long p;
freopen( "fact.in" , "rt", stdin );
scanf( "%ld", &p );
fclose( stdin );
long fac = 1, s = 0;
while( p > 0 )
{
s++;
p--;
fac = 5*s;
if( s%5 == 0 ) p -= s/5;
}
freopen( "fact.out", "wt", stdout );
printf ( "%ld", fac );
fclose( stdout );
return 0;
}