How to resolve the algorithm Catalan numbers/Pascal's triangle step by step in the Oforth programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Catalan numbers/Pascal's triangle step by step in the Oforth programming language

Table of Contents

Problem Statement

Print out the first   15   Catalan numbers by extracting them from Pascal's triangle.

Pascal's triangle

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Catalan numbers/Pascal's triangle step by step in the Oforth programming language

Source code in the oforth programming language

import: mapping

: pascal( n -- [] )  
   [ 1 ] n #[ dup [ 0 ] + [ 0 ] rot + zipWith( #+ ) ] times ;

: catalan( n -- m )
   n 2 * pascal at( n 1+ ) n 1+ / ;

  

You may also check:How to resolve the algorithm Mertens function step by step in the APL programming language
You may also check:How to resolve the algorithm Proper divisors step by step in the Tcl programming language
You may also check:How to resolve the algorithm Bitmap/Histogram step by step in the Kotlin programming language
You may also check:How to resolve the algorithm Mind boggling card trick step by step in the 11l programming language
You may also check:How to resolve the algorithm Wireworld step by step in the Icon and Unicon programming language