Cod sursa(job #136888)

Utilizator DraStiKDragos Oprica DraStiK Data 16 februarie 2008 12:52:49
Problema Factorial Scor 55
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.4 kb
#include <stdio.h>
#include <math.h>
long n,p;
int main ()
{
    freopen ("fact.in","r",stdin);
	freopen ("fact.out","w",stdout);
	int i,aux;
	scanf ("%d",&p);
	i=0;
	n=0;
	while (i<p)
	{
          n+=5;
          aux=n;
		  while (aux%5==0)
		  {
				i++;
				aux/=5;
          }   
    }
    if (i==p)
       printf ("%d",n);
    else 
         printf ("-1");
    return 0;
}