Cod sursa(job #203919)

Utilizator codruta.pocolcodruta pocol codruta.pocol Data 20 august 2008 18:15:00
Problema Factorial Scor 40
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.49 kb
program p_006;{factorial}
var p,i,n,t:longint;
begin
  assign(input,'fact.in'); reset(input);
  assign(output,'fact.out'); rewrite(output);
  readln(p);
  i:=0;
  if p=0 then write('1') else begin
    n:=5;
    while i<p do begin
      if n mod 25=0 then begin
        t:=n;
        while t mod 5=0 do begin t:=t div 5; i:=i+1; end;
        i:=i-1;
      end;
      n:=n+5; i:=i+1;
    end;
    if i=p then write(n-5) else write('-1');
  end;
  close(input); close(output);
end.