Pagini recente » Cod sursa (job #3192630) | Cod sursa (job #45485) | Cod sursa (job #1946920) | Cod sursa (job #435265) | Cod sursa (job #2237519)
#include <iostream>
#include <fstream>
using namespace std;
int main () {
int p, n = 1, putere = 1, y = 5;
bool gasit = false;
ifstream in ("fact.in");
in >> p;
in.close();
for (int i = 1; i <= p; i++) {
putere *= 5;
}
do {
if (n % putere == 0) {
if (n % (putere * 5) == 0) {
ofstream out ("fact.out");
out << -1;
out.close();
} else {
ofstream out ("fact.out");
out << y - 1;
out.close();
}
gasit = true;
}
n *= y;
y += 5;
} while (!gasit);
return 0;
}