Cod sursa(job #813081)

Utilizator AndreiDSADanaila Silviu Andrei AndreiDSA Data 14 noiembrie 2012 21:42:22
Problema Factorial Scor 15
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.6 kb
#include <iostream>
#include <fstream>
using namespace std;
int p,n;
void citire()
{
	ifstream f("fact.in");
	f>>p;
	f.close();
}
void factorial()
{
	int k,i,x;
	i=0;k=1;
	if(p<0)
		n=-1;
	else
		while(i<p)
		{
			n++;
			i=0;
			for(k=1;k<=n;k++)
			{
				x=k;
				if(k%10==0)
					while(x%10==0)
					{
						x=x/10;
						i++;
					}
				if(k%5==0)
					while(x%5==0)
					{
						x=x/5;
						i++;
					}
			}
		}
	if(n==0)
		n=1;
}
void tiparire()
{
	ofstream g("fact.out");
	g<<n;
	g.close();
}
int main()
{
	citire();
	factorial();
	tiparire();
	return 0;
}