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

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Floyd's triangle step by step in the Gambas 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 Gambas programming language

Source code in the gambas programming language

Public Sub Main()
Dim siCount, siNo, siCounter As Short
Dim siLine As Short = 1
Dim siInput As Short[] = [5, 14]

For siCount = 0 To siInput.Max
  Print "Floyd's triangle to " & siInput[siCount] & " lines"
  Do
    Inc siNo
    Inc siCounter
    Print Format(siNo, "####");
      If siLine = siCounter Then 
        Print 
        Inc siLine
        siCounter = 0
      End If
    If siLine - 1 = siInput[siCount] Then Break
  Loop
  siLine = 1
  siCounter = 0
  siNo = 0
  Print
Next

End

  

You may also check:How to resolve the algorithm Greatest subsequential sum step by step in the Phix programming language
You may also check:How to resolve the algorithm Cramer's rule step by step in the ALGOL 68 programming language
You may also check:How to resolve the algorithm Polyspiral step by step in the PARI/GP programming language
You may also check:How to resolve the algorithm Associative array/Creation step by step in the LFE programming language
You may also check:How to resolve the algorithm UTF-8 encode and decode step by step in the Kotlin programming language