Cod sursa(job #29972)
Utilizator | Alex Carp accxel | Data | 12 martie 2007 00:36:54 |
---|---|---|---|
Problema | Factorial | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.58 kb |
#include<fstream>
#include<math>
using namespace std;
long int fact(long int x)
{
long int i,prod=1;
for(i=1;i<=x;i++)
prod=prod*i;
return prod;
}
int main()
{
long int n,prod,p,gasit=0;
ifstream f("fact.in");
ofstream g("fact.out");
f>>p;
while(!gasit){
prod=fact(n);
if(prod%pow(10,p)==0)
gasit=1;
else
n++;
}
g<<n;
f.close();
g.close();
return 0;
}