How to resolve the algorithm Riordan numbers step by step in the Action! programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Riordan numbers step by step in the Action! programming language

Table of Contents

Problem Statement

Riordan numbers show up in several places in set theory. They are closely related to Motzkin numbers, and may be used to derive them. Riordan numbers comprise the sequence a where: There are other generating functions, and you are free to use one most convenient for your language.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Riordan numbers step by step in the Action! programming language

Source code in the action! programming language

;;; Find some Riordan numbers - limited to the first 13 as the largest integer
;;;                             Action! supports is unsigned 16-bit

;;; sets a to the riordan numbers 0 .. n, a must have n elements
PROC riordan( CARD n CARD ARRAY a )
  CARD i

  IF n >= 0 THEN
    a( 0 ) = 1
    IF n >= 1 THEN
      a( 1 ) = 0
      FOR i = 2 TO n DO
        a( i ) = ( ( i - 1 )
                 * ( ( 2 * a( i - 1 ) )
                   + ( 3 * a( i - 2 ) )
                   )
                 )
               / ( i + 1 )
      OD
    FI
  FI
RETURN

PROC Main()
  CARD  ARRAY r( 13 )
  CARD i

  riordan( 13, r )
  FOR i = 0 TO 12 DO
    Put( '  )
    PrintC( r( i ) )
  OD
RETURN

  

You may also check:How to resolve the algorithm Word frequency step by step in the Kotlin programming language
You may also check:How to resolve the algorithm Quickselect algorithm step by step in the Wren programming language
You may also check:How to resolve the algorithm Best shuffle step by step in the Delphi programming language
You may also check:How to resolve the algorithm Diversity prediction theorem step by step in the Scala programming language
You may also check:How to resolve the algorithm Write language name in 3D ASCII step by step in the Visual Basic .NET programming language