Cod sursa(job #1165768)

Utilizator LarryIulian Dutu Larry Data 2 aprilie 2014 21:49:37
Problema Factorial Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.4 kb
#include <fstream>
using namespace std;

unsigned fact(unsigned n)
{
	if(n>2)
		return n*fact(n-1);
	else
		return n;
}

int main()
{
	unsigned P;
	unsigned long long i;
	bool exista=0;
	ifstream f("fact.in");
	f>>P;
	f.close();
	ofstream g("fact.out");
	for(i=0;;i++)
		if(fact(i)%pow(10,P)==0)
		{
			g<<i;
			exista=1;
			break;
		}
	if(!exista)
		g<<-1;
	g.close();
	return 0;
}