How to resolve the algorithm Motzkin numbers step by step in the Maxima programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Motzkin numbers step by step in the Maxima programming language

Table of Contents

Problem Statement

The nth Motzkin number (denoted by M[n]) is the number of different ways of drawing non-intersecting chords between n points on a circle (not necessarily touching every point by a chord). By convention M[0] = 1.

Compute and show on this page the first 42 Motzkin numbers or, if your language does not support 64 bit integers, as many such numbers as you can. Indicate which of these numbers are prime.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Motzkin numbers step by step in the Maxima programming language

Source code in the maxima programming language

motzkin[0]:1$
motzkin[1]:1$
motzkin[n]:=((2*n+1)*motzkin[n-1]+(3*n-3)*motzkin[n-2])/(n+2)$

/* Test cases */
makelist(motzkin[i],i,0,41);

sublist(%,primep);


  

You may also check:How to resolve the algorithm Zero to the zero power step by step in the Stata programming language
You may also check:How to resolve the algorithm RCRPG step by step in the Erlang programming language
You may also check:How to resolve the algorithm Pointers and references step by step in the EchoLisp programming language
You may also check:How to resolve the algorithm Word ladder step by step in the Go programming language
You may also check:How to resolve the algorithm Duffinian numbers step by step in the Arturo programming language