Cod sursa(job #265297)
| Utilizator | Data | 23 februarie 2009 19:16:36 | |
|---|---|---|---|
| Problema | Factorial | Scor | 35 |
| Compilator | fpc | Status | done |
| Runda | Arhiva de probleme | Marime | 0.44 kb |
var p,nr,s,n:longint;
begin
assign(input,'fact.in');reset(input);
assign(output,'fact.out');rewrite(output);
readln(p);
s:=0;
nr:=0;
if p=0 then p:=1 else
if p<0 then p:=-1 else
begin
while nr<>p do begin
s:=s+5; inc(nr);
if (s mod 25=0) and (nr<>p) then begin
n:=s div 5; inc(nr);
while (n div 5 mod 5=0) and (nr<>p) do begin
n:=n div 5; inc(nr); end;
end;
end;
end;
write(s);
close(input);close(output);
end.
