How to resolve the algorithm Ackermann function step by step in the MUMPS programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Ackermann function step by step in the MUMPS programming language

Table of Contents

Problem Statement

The Ackermann function is a classic example of a recursive function, notable especially because it is not a primitive recursive function. It grows very quickly in value, as does the size of its call tree.

The Ackermann function is usually defined as follows:

Its arguments are never negative and it always terminates.

Write a function which returns the value of

A ( m , n )

{\displaystyle A(m,n)}

. Arbitrary precision is preferred (since the function grows so quickly), but not required.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Ackermann function step by step in the MUMPS programming language

Source code in the mumps programming language

Ackermann(m,n)	;
	If m=0 Quit n+1
	If m>0,n=0 Quit $$Ackermann(m-1,1)
	If m>0,n>0 Quit $$Ackermann(m-1,$$Ackermann(m,n-1))
	Set $Ecode=",U13-Invalid parameter for Ackermann: m="_m_", n="_n_","

Write $$Ackermann(1,8) ; 10
Write $$Ackermann(2,8) ; 19
Write $$Ackermann(3,5) ; 253

  

You may also check:How to resolve the algorithm Set step by step in the AppleScript programming language
You may also check:How to resolve the algorithm Sorting algorithms/Bubble sort step by step in the Fortran programming language
You may also check:How to resolve the algorithm Image noise step by step in the Delphi programming language
You may also check:How to resolve the algorithm Quine step by step in the Peri programming language
You may also check:How to resolve the algorithm Ordered words step by step in the Racket programming language