Cod sursa(job #178318)

Utilizator albuaAlbu Alexandru albua Data 14 aprilie 2008 13:29:31
Problema Factorial Scor 20
Compilator c Status done
Runda Arhiva de probleme Marime 0.46 kb
#include <stdio.h>

FILE *f,*g;
long i;
char ok;
long n,temp;

long calcp5(long x)
{
  long k,contor;
  k=5;
  contor=0;
  while(x/k!=0)
    {
	  contor+=x/k;
	  k*=5;
	}
  return contor;
}

int main()
{
  f=fopen("fact.in","r");
  g=fopen("fact.out","w");
  fscanf(f,"%ld\n",&n);
  i=5;
  ok=0;
  while(!ok)
	{
	  temp=calcp5(i);
	  if(temp==n) ok=1;
	  else i+=5;
	}
  fprintf(g,"%ld\n",i);
  fclose(f);   fclose(g);
  return 0;
}