Cod sursa(job #1438797)
| Utilizator | Data | 20 mai 2015 21:46:20 | |
|---|---|---|---|
| Problema | Factorial | Scor | 10 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.62 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream f ("fact.in");
ofstream g ("fact.out");
int power ( int a , int b)
{
int i;
int p=1;
for(i=1;i<=b;i++)
{
p=p*a;
}
return p;
}
int Factorial ( int n)
{
long long p=1;
while (n>0)
{
p=p*n;
n--;
}
return p;
}
int main()
{
bool gasit =false;
int p;
f>>p;
int i=0;
while ( gasit==false)
{
i++;
if( Factorial(i)%power(10, p )==0 ) {
gasit=true;
}
}
g<<i;
return 0;
}
