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

Published on 12 May 2024 09:40 PM

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

Source code in the factor programming language

USING: io kernel math math.functions math.ranges prettyprint
sequences ;
IN: rosetta-code.floyds-triangle

: floyd. ( n -- )
    [ dup 1 - * 2 / 1 + dup 1 ] [ [1,b] ] bi
    [
        [
            2dup [ log10 1 + >integer ] bi@ -
            [ " " write ] times dup pprint bl [ 1 + ] bi@
        ] times nl [ drop dup ] dip
    ] each nl 3drop ;

5 14 [ floyd. ] bi@


  

You may also check:How to resolve the algorithm Execute Brain step by step in the Swift programming language
You may also check:How to resolve the algorithm Sorting algorithms/Stooge sort step by step in the zkl programming language
You may also check:How to resolve the algorithm Greedy algorithm for Egyptian fractions step by step in the Python programming language
You may also check:How to resolve the algorithm Totient function step by step in the Forth programming language
You may also check:How to resolve the algorithm Quoting constructs step by step in the C++ programming language