Cod sursa(job #560076)
| Utilizator | Data | 18 martie 2011 12:19:30 | |
|---|---|---|---|
| Problema | Factorial | Scor | 10 |
| Compilator | fpc | Status | done |
| Runda | Arhiva de probleme | Marime | 0.42 kb |
function nr5(a:longint):word;
var i:integer;
begin
i:=0;
while a mod 5=0 do begin inc(i);a:=a div 5; end;
nr5:=i;
end;
var p,n,nr0,i:longint;
begin
assign(input,'fact.in');reset(input);
assign(output,'fact.out');rewrite(output);
readln(p);
if p=0 then write('1') else begin
n:=1;
while n*5<p*5 do begin n:=n*5;inc(i);end;
write(p*5-(5*(i*(i-1)div 2)));
end;
close(input);close(output);
end.