Cod sursa(job #187129)
Utilizator | alex puscas alex-P | Data | 30 aprilie 2008 20:46:44 |
---|---|---|---|
Problema | Factorial | Scor | 25 |
Compilator | fpc | Status | done |
Runda | Arhiva de probleme | Marime | 0.62 kb |
var n:longint;
p:longint;
f:text;
procedure citire;
var f:text;
begin
assign(f,'fact.in');
reset(f);
read(f,p);
close(f);
end;
function cinci(n:longint):longint;
begin
if n mod 5 = 0 then cinci:=1+cinci(n div 5)
else cinci:=0;
end;
begin
citire;
assign(f,'fact.out');
rewrite(f);
n:=0;
if p=0 then write (f,'1')
else begin while p>0 do
begin
n:=n+5;
p:=p-cinci(n);
end;
write(f,n);
end;
close(f);
end.