Pagini recente » Cod sursa (job #479333) | Cod sursa (job #2427753) | Cod sursa (job #1351205) | Cod sursa (job #1668622) | Cod sursa (job #2559436)
#include <iostream>
#include <fstream>
using namespace std;
ifstream in("fact.in");
ofstream out("fact.out");
int power( int base, int exp);
long long int factorial(int n);
int main() {
long long int p, n, f, op;
in >> p;
/*if (p > 0) { out << p * 5; }
else if (p == 0) { out << 1; }
else { out << -1; }
*/
op = power(10, p);
n = 1;
f = factorial(n);
while (f % op != 0) {
n++;
f = factorial(n);
}
if (n >= 1) { out << n; }
else{ out << -1;}
return 0;
}
int power(int base, int exp) {
int result = 1;
for (int c = 1;c <=exp;c++) {
result = result * base;
}
return result;
}
long long int factorial(int n) {
if (n > 0) { return(n * factorial(n - 1)); }
else return 1;
}