How to resolve the algorithm Count in octal step by step in the S-BASIC programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Count in octal step by step in the S-BASIC programming language

Table of Contents

Problem Statement

Produce a sequential count in octal,   starting at zero,   and using an increment of a one for each consecutive number. Each number should appear on a single line,   and the program should count until terminated,   or until the maximum value of the numeric type in use is reached.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Count in octal step by step in the S-BASIC programming language

Source code in the s-basic programming language

rem - return p mod q
function mod(p, q = integer) = integer
end = p - q * (p / q)

rem - return octal representation of n
function oct$(n = integer) = string
var s = string
s = ""
while n > 0 do
  begin
     s = chr(mod(n,8) + '0') + s
     n = n / 8
  end
end = s

rem - count in octal until overflow
var i = integer
i = 1
while i > 0 do
  begin
    print oct$(i)
    i = i + 1
  end

end


  

You may also check:How to resolve the algorithm Menu step by step in the HicEst programming language
You may also check:How to resolve the algorithm Cantor set step by step in the QB64 programming language
You may also check:How to resolve the algorithm 15 puzzle game step by step in the M2000 Interpreter programming language
You may also check:How to resolve the algorithm Arithmetic-geometric mean step by step in the Common Lisp programming language
You may also check:How to resolve the algorithm 24 game step by step in the PARI/GP programming language