Cod sursa(job #163349)

Utilizator LoLFactorPascu Vlad LoLFactor Data 22 martie 2008 00:14:24
Problema Factorial Scor 5
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.38 kb
#include<fstream>
using namespace std;

long fact(long x){
	if(x == 1) return 1;
	else return x * fact(x - 1);
}

int nr(long x){
	int ret = 0;
	while(x % 10 == 0){
		ret++;
		x /= 10;
	}

return ret;
}

int main(){
	fstream in("fact.in", ios::in), out("fact.out", ios::out);
	long p, i;
	in >> p;
	for(i = p * 3;;i++){
		if(nr(fact(i)) == p) break;
	}
	out << i;
}