Pagini recente » Cod sursa (job #2355582) | Cod sursa (job #2391880) | Cod sursa (job #368166) | Cod sursa (job #391119) | Cod sursa (job #824239)
Cod sursa(job #824239)
#include <iostream>
#include <fstream>
using namespace std;
int main(){
ifstream f("fact.in");
int P, nr=0;
f>>P;
f.close();
/*
while(P>0){
nr=nr+5;
if(nr%5==0){
int k=nr;
while(k%5==0){
P--;
k=k/5;
}
}
}
*/
while(P>=5){
nr=nr+25;
P=P-4;
int k=nr;
while(k%5==0){
P--;
k=k/5;
}
}
while(P>0){
nr=nr+5;
int k=nr;
while(k%5==0){
P--;
k=k/5;
}
}
if(nr==0) nr=1;
if(P<0) nr=-1;
ofstream g("fact.out");
g<<nr;
g.close();
return 0;
}