How to resolve the algorithm Catalan numbers step by step in the Seed7 programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Catalan numbers step by step in the Seed7 programming language

Table of Contents

Problem Statement

Catalan numbers are a sequence of numbers which can be defined directly: Or recursively: Or alternatively (also recursive):

Implement at least one of these algorithms and print out the first 15 Catalan numbers with each. Memoization   is not required, but may be worth the effort when using the second method above.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Catalan numbers step by step in the Seed7 programming language

Source code in the seed7 programming language

$ include "seed7_05.s7i";
  include "bigint.s7i";

const proc: main is func
  local
    var bigInteger: n is 0_;
  begin
    for n range 0_ to 15_ do
      writeln((2_ * n) ! n div succ(n));
    end for;
  end func;

  

You may also check:How to resolve the algorithm Jordan-Pólya numbers step by step in the Wren programming language
You may also check:How to resolve the algorithm Galton box animation step by step in the Elm programming language
You may also check:How to resolve the algorithm Harshad or Niven series step by step in the PILOT programming language
You may also check:How to resolve the algorithm UTF-8 encode and decode step by step in the Python programming language
You may also check:How to resolve the algorithm Fibonacci sequence step by step in the Ada programming language