Cod sursa(job #545484)

Utilizator alia_deiCristina Sirbu alia_dei Data 3 martie 2011 14:12:28
Problema Factorial Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.42 kb
#include<iostream.h>
#include<fstream.h>

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

int main()
{
	ifstream f;
	f.open("fact.in");
	ofstream g;
	g.open("fact.out");
	long int p;
	f>>p;
	int ok=0;
	int i=1;
	while (!ok)
	{
		//i=1;
		int y=fact(i);
		int k=0;
		while (y%10==0)
		{
			k++;
			y=y/10;
		}
		if (k==p) ok=1;
		else i++;
	}
	if (ok) g<<i;
			
	return 0;
}