Pagini recente » Cod sursa (job #2135120) | Cod sursa (job #2563189) | Cod sursa (job #2471824) | Cod sursa (job #1173183) | Cod sursa (job #1326918)
#include <fstream>
#include <iostream>
using namespace std;
int main()
{
long long p,n,i,aux,cnt,aux1;
ifstream fin("fact.in");
fin>>p;
i=1;
n=1;
aux=p;
cnt=0;
while(aux>0)
{
++i;
n*=i;
if(n%10==0) {aux--;aux1=n/10;}
while(n%10==0)
{
cnt++;
n/=10;
}
n=aux1;
}
if(cnt-p==0)
p*=5;
if(cnt-p==1)
p=(p-1)*5;
if(cnt-p==2)
p=(p-2)*5;
if(cnt-p==3)
p=(p-3)*5;
if(cnt-p==4)
p=(p-4)*5;
if(cnt-p==5)
p=(p-5)*5;
if(cnt-p==6)
p=(p-6)*5;
if(cnt-p==7)
p=(p-7)*5;
ofstream fout("fact.out");
fout<<p;
fout.close();
return 0;
}