Cod sursa(job #358821)
| Utilizator | Data | 24 octombrie 2009 16:56:41 | |
|---|---|---|---|
| Problema | Factorial | Scor | 0 |
| Compilator | fpc | Status | done |
| Runda | Arhiva de probleme | Marime | 0.44 kb |
var p,n,i:longint;
function div5(x:longint):byte;
begin
if (x mod 5<>0) or (x=0) then div5:=0
else div5:=div5(x div 5)+1;
end;
begin
assign(input,'fact.in');reset(input);
assign(output,'fact.out');rewrite(output);
readln(p);
n:=5; dec(p);
while p>0 do begin
i:=div5(n);
n:=n+i*5;
p:=p-i;
end;
if p<>0 then n:=n-abs(p)*5
else n:=n-5;
write(n);
close(input);close(output);
end.
