Module:Temperament data: Difference between revisions

CompactStar (talk | contribs)
No edit summary
ArrowHead294 (talk | contribs)
CLN-UP
Line 4: Line 4:


local function gcd(a,b)
local function gcd(a,b)
  if type(a) == 'number' and type(b) == 'number' and  
    if type(a) == 'number' and type(b) == 'number' and a == math.floor(a) and b == math.floor(b) then
        a == math.floor(a) and b == math.floor(b) then
        if b == 0 then
    if b == 0 then
            return a
      return a
        else
            return gcd(b, a % b) -- tail recursion
        end
     else
     else
      return gcd(b, a % b) -- tail recursion
        error('Invalid argument to gcd (' .. tostring(a) .. ',' .. tostring(b) .. ')', 2)
     end
     end
  else
    error('Invalid argument to gcd (' .. tostring(a) .. ',' ..
          tostring(b) .. ')', 2)
  end
end
end


Line 327: Line 325:
return result
return result
end
end


return p
return p