Gray code: Difference between revisions

Content deleted Content added
Markjreed (talk | contribs)
→‎{{header|Lua}}: Add output.
Markjreed (talk | contribs)
m →‎{{header|Lua}}: improve formatter
Line 996:
-- simple binary string formatter
local function to_bit_string(n, width)
ifwidth = width thenor 1
local output = ""
while n > 0 do
Line 1,001 ⟶ 1,002:
n = bit.rshift(n,1)
end
ifwhile #output ==< 0width thendo
output = "'0"' .. output
end
if width then
while #output < width do
output = '0' .. output
end
end
return output