How to resolve the algorithm Catalan numbers/Pascal's triangle step by step in the Erlang 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 Erlang 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 Erlang programming language

Source code in the erlang programming language

-module(catalin).
-compile(export_all).
mul(N,D,S,S)-> 
	N2=N*(S+S),
	D2=D*S,
	K = N2 div D2 ;
mul(N,D,S,L)->
	N2=N*(S+L),
	D2=D*L,
	K = mul(N2,D2,S,L+1).
	
catl(Ans,16) -> Ans;
catl(D,S)->
	C=mul(1,1,S,2),
	catl([D|C],S+1).
main()->
	Ans=catl(1,2).


  

You may also check:How to resolve the algorithm Product of min and max prime factors step by step in the PL/M programming language
You may also check:How to resolve the algorithm Range expansion step by step in the R programming language
You may also check:How to resolve the algorithm Caesar cipher step by step in the Elixir programming language
You may also check:How to resolve the algorithm Ultra useful primes step by step in the J programming language
You may also check:How to resolve the algorithm Dice game probabilities step by step in the J programming language