Cod sursa(job #305621)

Utilizator danalex97Dan H Alexandru danalex97 Data 17 aprilie 2009 22:27:27
Problema Factorial Scor 35
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.44 kb
procedure lucru(var c:longint;n:longint);
begin
while n mod 5=0 do
  begin
    n:=n div 5;
    inc(c);
  end;
end;

var p,n,c,k:longint;
    f,g:text;

begin
assign(f,'fact.in');
reset(f);
assign(g,'fact.out');
rewrite(g);
read(f,p);
if (p>0) then
begin
while c<p do
  begin
    inc(n,5);
    lucru(c,n);
  end;
if c=p then write(g,n)
       else write(g,'-1');
end
else
if p=0 then write(g,'1');
close(f);
close(g);
end.