Cod sursa(job #1667166)
Utilizator | Ciobanu Alin-Matei CIOBBYX | Data | 28 martie 2016 18:31:09 |
---|---|---|---|
Problema | Factorial | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.46 kb |
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <fstream>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
long long n=5,p;
long long f(long long n) {
int i=1,s=0;
while (n/pow(5,i)) {
s+=n/pow(5,i);
i++;
}
return s;
}
long long factorial (long long n,long long p) {
if (f(n)==p) return n;
else return factorial(n+1,p);
}
int main()
{
fin>>p;
fout<<factorial(5,p);
return 0;
}