Cod sursa(job #504186)

Utilizator bobomitzRauca Mihai bobomitz Data 26 noiembrie 2010 22:17:46
Problema Factorial Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.43 kb
#include<fstream>
using namespace std;

void main()
{
	long int P, N, CPN, i=2, j, pp=0, n=0;
	ifstream fin("fact.in");
	ofstream fout("fact.out");
	fin>>P;
    while(pp==0)
	{
		CPN=1;
		n=0;
		for(j=1;j<=i;j++)
			CPN*=j;
		    N=i;
		while(CPN!=0)
		{
			if(CPN%10==0)
				n++;
			if(CPN%10!=0)
				break;
			CPN/=10;
		}
		if(n==P)
		{
			pp=1;
			fout<<N;
		}
		i++;
	}
	fin.close();
	fout.close();
}