Count in octal: Difference between revisions
Content added Content deleted
(→Whitespace: Add implementation) |
(→Brainf***: Add implementation) |
||
Line 162: | Line 162: | ||
& whl'(1+!n:?n&out$(!n oct$!n)); |
& whl'(1+!n:?n&out$(!n oct$!n)); |
||
</lang> |
</lang> |
||
=={{header|Brainf***}}== |
|||
<lang bf>+[ Start with n=1 to kick off the loop |
|||
[>>++++++++<< Set up {n 0 8} for divmod magic |
|||
[->+>- Then |
|||
[>+>>]> do |
|||
[+[-<+>]>+>>] the |
|||
<<<<<<] magic |
|||
>>>+ Increment n % 8 so that 0s don't break things |
|||
>] Move into n / 8 and divmod that unless it's 0 |
|||
-< Set up sentinel ‑1 then move into the first octal digit |
|||
[++++++++ ++++++++ ++++++++ Add 47 to get it to ASCII |
|||
++++++++ ++++++++ +++++++. and print it |
|||
[<]<] Get to a 0; the cell to the left is the next octal digit |
|||
>>[<+>-] Tape is {0 n}; make it {n 0} |
|||
>[>+] Get to the ‑1 |
|||
<[[-]<] Zero the tape for the next iteration |
|||
++++++++++. Print a newline |
|||
[-]<+] Zero it then increment n and go again</lang> |
|||
=={{header|C}}== |
=={{header|C}}== |