Count in octal: Difference between revisions
Content deleted Content added
Forth |
→{{header|Lua}}: Add Logo. |
||
Line 343: | Line 343: | ||
} |
} |
||
}</lang> |
}</lang> |
||
=={{header|Logo}}== |
|||
No built-in octal-formatting, so it's probably more efficient to just manually increment a string than to increment a number and then convert the whole thing to octal every time we print. |
|||
<lang logo>to increment_octal :number |
|||
ifelse [empty? :n] [ |
|||
output 1 |
|||
] [ |
|||
local "last |
|||
make "last last :n |
|||
local "butlast |
|||
make "butlast butlast :n |
|||
make "last sum :last 1 |
|||
ifelse [:last < 8] [ |
|||
output word :butlast :last |
|||
] [ |
|||
output word (next_octal_number :butlast) 0 |
|||
] |
|||
] |
|||
end |
|||
make "oct 1 |
|||
while ["true] [ |
|||
print :oct |
|||
make "oct increment_octal :oct |
|||
]</lang> |
|||
=={{header|Lua}}== |
=={{header|Lua}}== |