Count in octal: Difference between revisions

Content added Content deleted
(I added Salmon code.)
(→‎{{header|PL/I}}: Added PureBasic)
Line 627: Line 627:
end count;
end count;
</lang>
</lang>
=={{header|PureBasic}}==
<lang PureBasic>Procedure.s octal(n.q)
Static Dim digits(20)
Protected i, j, result.s
For i = 0 To 20
digits(i) = n % 8
n / 8
If n < 1
For j = i To 0 Step -1
result + Str(digits(j))
Next
Break
EndIf
Next
ProcedureReturn result
EndProcedure

Define n.q
If OpenConsole()
While n >= 0
PrintN(octal(n))
n + 1
Wend
Print(#CRLF$ + #CRLF$ + "Press ENTER to exit"): Input()
CloseConsole()
EndIf
</lang>
Sample output:
<pre>0
1
2
3
4
5
6
7
10
11
12
...
777777777777777777767
777777777777777777770
777777777777777777771
777777777777777777772
777777777777777777773
777777777777777777774
777777777777777777775
777777777777777777776
777777777777777777777</pre>


=={{header|Python}}==
=={{header|Python}}==