Module:Rational: Difference between revisions

Plumtree (talk | contribs)
m pow() and modulo_mul() implemented
Plumtree (talk | contribs)
m divisors() implemented
Line 347: Line 347:
end
end
return max_factor
return max_factor
end
-- determine the number of rational divisors
function p.divisors(a)
if type(a) == 'number' then
a = p.new(a)
end
if a.nan or a.inf or a.zero then
return 0
end
local d = 1
for factor, power in pairs(a) do
if type(factor) == 'number' then
d = d * (math.abs(factor) + 1)
end
end
return d
end
end