Module:Interval table: Difference between revisions

CompactStar (talk | contribs)
No edit summary
CompactStar (talk | contribs)
No edit summary
Line 5: Line 5:
local ud = require('Module:Ups and downs notation')
local ud = require('Module:Ups and downs notation')
local ET = require('Module:ET')
local ET = require('Module:ET')
local function gcd(a, b)
return b==0 and a or gcd(b,a%b)
end


-- Generates list of ratios up to a max numerator & denominator, and max ratio size  
-- Generates list of ratios up to a max numerator & denominator, and max ratio size  
Line 12: Line 16:
for j=1,max_nd do
for j=1,max_nd do
if (i/j) >= 1 and (i/j) <= max_size then
if (i/j) >= 1 and (i/j) <= max_size then
ratios[#ratios + 1] = {i/u.gcd(i,j),j/u.gcd(i,j)}
ratios[#ratios + 1] = {i/gcd(i,j),j/gcd(i,j)}
end
end
end
end