Cod sursa(job #2681359)
Utilizator | Data | 5 decembrie 2020 12:03:33 | |
---|---|---|---|
Problema | Factorial | Scor | 50 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.62 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
int n;
int p;
int nr5;
int main()
{
fin >> p;
int j = 1;
if (p == 0)
fout << 1;
else
{
while (nr5 < p)
{
n += 5;
nr5++;
if (j % 5 == 0)
{
int x = j;
while (x % 5 == 0)
{
x /= 5;
nr5++;
}
}
j++;
}
fout << n;
}
fin.close();
fout.close();
return 0;
}