How to resolve the algorithm Floyd's triangle step by step in the OxygenBasic programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Floyd's triangle step by step in the OxygenBasic programming language

Table of Contents

Problem Statement

Floyd's triangle   lists the natural numbers in a right triangle aligned to the left where

The first few lines of a Floyd triangle looks like this:

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Floyd's triangle step by step in the OxygenBasic programming language

Source code in the oxygenbasic programming language

function Floyd(sys n) as string
sys i,t
for i=1 to n
  t+=i
next
string s=str t
sys le=1+len s
string cr=chr(13,10)
sys lc=len cr
string buf=space(le*t+n*lc)
sys j,o,p=1
t=0
for i=1 to n
  for j=1 to i
    t++
    s=str t
    o=le-len(s)-1 'right justify
    mid buf,p+o,str t
    p+=le
  next
  mid buf,p,cr
  p+=lc
next
return left buf,p-1
end function

putfile "s.txt",Floyd(5)+floyd(14)

  

You may also check:How to resolve the algorithm World Cup group stage step by step in the Java programming language
You may also check:How to resolve the algorithm Cartesian product of two or more lists step by step in the Erlang programming language
You may also check:How to resolve the algorithm HTTPS step by step in the Ada programming language
You may also check:How to resolve the algorithm Iterated digits squaring step by step in the Nim programming language
You may also check:How to resolve the algorithm Program termination step by step in the AppleScript programming language