RosettaCodeData/Task/Count-in-octal/Liberty-BASIC/count-in-octal-2.basic
2023-07-01 13:44:08 -04:00

30 lines
658 B
Text

op$ = "00000000000000000000"
L =len( op$)
while 1
started =0
for i =1 to L
m$ =mid$( op$, i, 1)
if started =0 and m$ ="0" then print " "; else print m$;: started =1
next i
print
for i =L to 1 step -1
p$ =mid$( op$, i, 1)
if p$ =" " then v =0 else v =val( p$)
incDigit = v +carry
if i =L then incDigit =incDigit +1
if incDigit >=8 then
replDigit =incDigit -8
carry =1
else
replDigit =incDigit
carry =0
end if
op$ =left$( op$, i -1) +chr$( 48 +replDigit) +right$( op$, L -i)
next i
wend
end