Cod sursa(job #40242)
Utilizator | Data | 27 martie 2007 12:15:30 | |
---|---|---|---|
Problema | Factorial | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.53 kb |
#include <fstream>
#include <math.h>
using namespace std;
ifstream in("fact.in");
ofstream out("fact.out");
int n, p, s;
main()
{
int k=1, P=1;
in>>p;
while(s!=p)
{
s=0;
n+=1;
while( P*5<=n )
{
P*=5;
k++;
}
for(int i=1;i<=k;i++)
s+=n / (pow(5, i));
}
out<<n;
}