Pagini recente » Cod sursa (job #271327) | Cod sursa (job #472889) | Cod sursa (job #2692719) | Cod sursa (job #111000) | Cod sursa (job #1438797)
#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;
}