Pagini recente » Cod sursa (job #2164990) | Cod sursa (job #1673130) | Cod sursa (job #2342141) | Cod sursa (job #2624619) | Cod sursa (job #1375556)
#include <iostream>
#include <fstream>
#include <cmath>
using namespace std;
int main()
{ifstream in;
ofstream out;
long long int P, i = 0, o = 0, M = 1, k;
in.open("fact.in");
in >> P;
in.close();
bool cifre = false;
if (P == 0)
{cifre = true;
i = 1;}
while (cifre == false)
{o = 0;
i = i + 1;
if (i % 5 == 0 || i == 4)
{M = M*i;
while (M % 3 == 0) M = M / 3;}
k = M;
if (i % 5 == 0)
{while (k % 10 == 0)
{o = o + 1;
k = k / 10;}}
if (o == P)
{cifre = true;}
else if (o > P)
{cifre = true;
i = -1;}}
out.open("fact.out");
out << i;
out.close();
return 0;
}