Pagini recente » Rating Ioana Gavrilescu (IoanaGavrilescu) | Cod sursa (job #2530466) | Profil StefanLazar9 | Diferente pentru home intre reviziile 194 si 193 | Cod sursa (job #1720543)
#include <iostream>
#include <fstream>
using namespace std;
int pow5(int);
int main()
{
long p;
int i,n,x;
n = 1;
i = 1;
ifstream fin("fact.in");
ofstream fout("fact.out");
fin >> p;
while (p > 0){
n = i * 5;
x = pow5(i);
p = p -x -1;
i++;
}
if (p == 0)
fout << n;
else fout << -1;
return 0;
}
int pow5(int x){
int exp = 0;
while (x % 5 == 0){
exp++;
x = x/5;
}
return exp;
}