Cod sursa(job #349149)

Utilizator shnakoVlad Schnakovszki shnako Data 18 septembrie 2009 10:50:14
Problema Factorial Scor 65
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.33 kb
#include <stdio.h>
FILE *f=fopen("fact.in", "r"), *g=fopen("fact.out", "w");
long x, p, i;
int main(void)
{
	fscanf(f, "%ld", &p);
	if(!p)
	{
		fprintf(g, "1");
		return 0;
	}
	for (i=1;p;i++)
	{
		x=i;
		p--;
		if(x%5==0)
			while (x%5==0)
			{
				x/=5;
				p--;
			}
	}
	fprintf(g, "%ld", 5*(i-1));
	return 0;
}