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

Published on 12 May 2024 09:40 PM

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

Source code in the bracmat programming language

  ( ( floyd
    =   lowerLeftCorner lastInColumn lastInRow row i W w
      .   put$(str$("Floyd " !arg ":\n"))
        &   !arg*(!arg+-1)*1/2+1
          : ?lowerLeftCorner
          : ?lastInColumn
        & 1:?lastInRow:?row:?i
        &   whl
          ' ( !row:~>!arg
            & @(!lastInColumn:? [?W)
            & @(!i:? [?w)
            & whl'(!w+1:~>!W:?w&put$" ")
            & put$!i
            & (   !i:
                & put$" "
                & 1+!lastInColumn:?lastInColumn
              |   put$\n
                & (1+!row:?row)+!lastInRow:?lastInRow
                & !lowerLeftCorner:?lastInColumn
              )
            & 1+!i:?i
            )
    )
  & floyd$5
  & floyd$14
  );

  

You may also check:How to resolve the algorithm Semiprime step by step in the Phix programming language
You may also check:How to resolve the algorithm Find if a point is within a triangle step by step in the Haskell programming language
You may also check:How to resolve the algorithm Non-decimal radices/Convert step by step in the Ruby programming language
You may also check:How to resolve the algorithm Call a foreign-language function step by step in the Phix programming language
You may also check:How to resolve the algorithm Trigonometric functions step by step in the JavaScript programming language