Pagini recente » Cod sursa (job #1031982) | Cod sursa (job #2586588) | Cod sursa (job #321418) | Cod sursa (job #2897567) | Cod sursa (job #1011197)
#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);
return getn(x+1,nrz);
}
int main()
{
int p,n;
ifstream f("fact.in");
f>>p;
f.close();
n=(p==0)?1:getn(1,p);
ofstream g("fact.out");
g<<n;
g.close();
return 0;
}