Cod sursa(job #188868)
Utilizator | alex puscas alex-P | Data | 10 mai 2008 12:23:51 |
---|---|---|---|
Problema | Factorial | Scor | 90 |
Compilator | fpc | Status | done |
Runda | Arhiva de probleme | Marime | 0.63 kb |
var n,p:longint;
f:text;
procedure citire;
var f:text;
begin
assign(f,'fact.in');
reset(f);
read(f,p);
close(f);
end;
function cinci(m,x,putere:longint):longint;
begin
if (p>=m)or(p>=m-putere+1) then cinci:=cinci(m+x,x*5,putere+1)
else begin cinci:=m-x div 5; n:=n+x div 5 end
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
p:=p-cinci(0,1,0);
end;
write(f,n);
end;
close(f);
end.