Evaluate binomial coefficients: Difference between revisions

Content added Content deleted
m (→‎{{header|Lua}}: handle overflow by switching to double approximate)
m (→‎{{header|Lua}}: not save some out of normal(?) inputs bound case)
Line 1,189: Line 1,189:
local ans = self[hash]
local ans = self[hash]
if not ans then
if not ans then
if n<=1 or k==0 or k==n then
if n<0 or k>n then
return 0 -- not save
elseif n<=1 or k==0 or k==n then
ans = 1
ans = 1
elseif k>n then
ans = 0
else
else
if 2*k > n then
if 2*k > n then