How to resolve the algorithm Sudan function step by step in the Arturo programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Sudan function step by step in the Arturo programming language
Table of Contents
Problem Statement
The Sudan function is a classic example of a recursive function, notable especially because it is not a primitive recursive function. This is also true of the better-known Ackermann function. The Sudan function was the first function having this property to be published. The Sudan function is usually defined as follows (svg):
F
0
( x , y )
= x + y
F
n + 1
( x , 0 )
= x
if
n ≥ 0
F
n + 1
( x , y + 1 )
=
F
n
(
F
n + 1
( x , y ) ,
F
n + 1
( x , y ) + y + 1 )
if
n ≥ 0
{\displaystyle {\begin{array}{lll}F_{0}(x,y)&=x+y\F_{n+1}(x,0)&=x&{\text{if }}n\geq 0\F_{n+1}(x,y+1)&=F_{n}(F_{n+1}(x,y),F_{n+1}(x,y)+y+1)&{\text{if }}n\geq 0\\end{array}}}
Write a function which returns the value of F(x, y).
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Sudan function step by step in the Arturo programming language
Source code in the arturo programming language
sudan: function [n, x, y][
if n = 0 -> return x + y
if y = 0 -> return x
sudan n-1 sudan n x y-1 y + sudan n x y-1
]
print sudan 1 3 3
You may also check:How to resolve the algorithm Numerical integration step by step in the PARI/GP programming language
You may also check:How to resolve the algorithm Amb step by step in the TUSCRIPT programming language
You may also check:How to resolve the algorithm Permutations by swapping step by step in the Kotlin programming language
You may also check:How to resolve the algorithm File size step by step in the Ruby programming language
You may also check:How to resolve the algorithm Stair-climbing puzzle step by step in the Liberty BASIC programming language