Module:Utils: Difference between revisions

Plumtree (talk | contribs)
1 is not a prime
Plumtree (talk | contribs)
mNo edit summary
Line 74: Line 74:


-- cached list of primes for is_prime
-- cached list of primes for is_prime
local primes = {[1] = false}
local primes = {
[0] = false,
[1] = false
}


-- returns true if integer n is prime; cannot be used with {{#invoke:}}
-- returns true if integer n is prime; cannot be used with {{#invoke:}}
Line 120: Line 123:


function p._prime_factorization(n)
function p._prime_factorization(n)
if n == 1 then
if n <= 1 then
return "1"
return tostring(n)
end
end
local factors, powers = {}, {}
local factors, powers = {}, {}