Cod sursa(job #602868)

Utilizator Andru_Andru Felipe Zuniga Andru_ Data 13 iulie 2011 16:10:57
Problema Factorial Scor 20
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.42 kb
program factorial;
var
 p,n,s,temp:longint;
 f,g:text;
 gasit:boolean;
begin
 assign(f,'fact.in');
 assign(g,'fact.out');
 reset(f);
 read(f,p);
 close(f);
 rewrite(g);
 n:=p;
 repeat
  n:=n+1;
  s:=0;
  temp:=n;
  repeat
   s:=s+temp div 5;
   temp:=temp div 5;
  until temp=0;
  if s=p then
   gasit:=true;
 until (gasit=true) or (s>p);
 if s>p then
  write(g,'-1')
 else
  write(g,n);
 close(g);
end.