Pagini recente » Cod sursa (job #2031029) | Cod sursa (job #1819038) | Arhiva de probleme, pregatire pentru concursuri de informatica | Cod sursa (job #1439344) | Cod sursa (job #1011198)
#include<iostream>
#include<fstream>
using namespace std;
long long fact(long long x)
{
if(x==0)
return 1;
return x*fact(x-1);
}
int nrDeCinci(int x)
{
if(x%5!=0)
return 0;
if(x<5)
return 0;
return 1+nrDeCinci(x/5);
}
int getn(int x,int nrz)
{
if(nrz == 0)
return 5*(x-1);
if(nrz < 0)
return -1;
do
{
nrz--;
x/=5;
}while(x%5==0 && x!=0);
return getn(x+1,nrz);
}
int main()
{
int p,n;
ifstream f("fact.in");
f>>p;
f.close();
p=2;
n=(p==0)?1:getn(1,p);
ofstream g("fact.out");
g<<n;
g.close();
return 0;
}