Module:Primes in edo fs: Difference between revisions

Xenwolf (talk | contribs)
make fs parameter accept defined switches: 1 as number and 1 as string
Xenwolf (talk | contribs)
force sign for non-zero fifthspans
Line 1: Line 1:
local p = {}
local p = {}


-- https://rosettacode.org/wiki/Greatest_common_divisor#Lua
-- greatest common divisor of a and b
-- source: https://rosettacode.org/wiki/Greatest_common_divisor#Lua
local function gcd(a, b)
local function gcd(a, b)
     while b ~= 0 do  
     while b ~= 0 do  
Line 86: Line 87:
           rsp = rsp - edo
           rsp = rsp - edo
         end
         end
        local sig = ''
         if rsp ~= 0 then
         if rsp > 0 then
          rsp = string.format('%+.0f', rsp)
          sig = '+'
        elseif rsp < 0 then
          sig = '−'
         end
         end
         table.insert(fspans, ' '.. fmt_sign(rsp))
         table.insert(fspans, ' '.. fmt_sign(rsp))