Module:Rational: Difference between revisions
m is_power() implemented |
m as_ket() improved |
||
Line 1,116: | Line 1,116: | ||
local max_prime = p.max_prime(a) | local max_prime = p.max_prime(a) | ||
local template_arg = '' | local template_arg = '' | ||
local template_arg_without_trailing_zeros = '' | |||
local zeros_n = 0 | |||
for i = 2, max_prime do | for i = 2, max_prime do | ||
if u.is_prime(i) then | if u.is_prime(i) then | ||
if i > 2 then template_arg = template_arg .. ' ' end | if i > 2 then | ||
template_arg = template_arg .. ' ' | |||
end | |||
template_arg = template_arg .. (a[i] or 0) | template_arg = template_arg .. (a[i] or 0) | ||
if (a[i] or 0) ~= 0 then | |||
if zeros_n >= 4 then | |||
template_arg = template_arg_without_trailing_zeros | |||
if #template_arg > 0 then | |||
template_arg = template_arg .. ' ' | |||
end | |||
template_arg = template_arg .. '0<sup>' .. zeros_n .. '</sup> ' .. (a[i] or 0) | |||
end | |||
zeros_n = 0 | |||
template_arg_without_trailing_zeros = template_arg | |||
else | |||
zeros_n = zeros_n + 1 | |||
end | |||
end | end | ||
end | end |