Cod sursa(job #253529)

Utilizator andrey932Andrei andrey932 Data 5 februarie 2009 21:54:28
Problema Factorial Scor 0
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.34 kb
var p,n,zero,j:longint;
var t:text;
begin
zero:=0;
n:=0;
assign(t,'fact.in'); reset(t);
readln(t,p);
repeat
  begin
    n:=n+1;
    j:=n;
    while j mod 5 = 0 do
      begin
        zero:=zero+1;
        j:=j div 5;
      end;

  end;
until zero>=p;
close(t);
if zero=p then writeln(n)
  else writeln('-1');
readln;
end.