Module:Infobox chord: Difference between revisions
m link directly to Euler-Fokker genus; we might want to make genus into a disambiguation page |
reduce harmonics to simplest terms before computing data |
||
Line 43: | Line 43: | ||
table.insert(harmonics, h) | table.insert(harmonics, h) | ||
end | end | ||
-- reduce harmonics to simplest terms, in case the user accidentally failed to reduce them | |||
local gcd = harmonics[1] | |||
for i, h in ipairs(harmonics) do | |||
gcd = utils._gcd(gcd, h) | |||
if gcd == 1 then break end | |||
end | |||
if gcd > 1 then | |||
for i, h in ipairs(harmonics) do | |||
harmonics[i] = harmonics[i] / gcd | |||
end | |||
end | |||
local root = harmonics[1] | local root = harmonics[1] | ||
if utils.value_provided(frame.args["Root"]) then | if utils.value_provided(frame.args["Root"]) then |