Nios/ackermann
From ASMBits
nios/treedepthPrevious
Nextnios/findstack
The Ackermann function is a function of two parameters that grows very quickly. It is often defined recursively:
unsigned int ackermann (unsigned int m, unsigned int n) {
if (m==0) return n+1;
else if (n==0) return ackermann(m-1, 1);
else return ackermann(m-1, ackermann(m, n-1) );
}
Write a function with two parameters named ackermann that will compute the value of the Ackermann function for the two parameters.
You may assume that the input will be small enough to not overflow and will run in a reasonable amount of time when implemented using the above recursive formulation.
Expected solution length: Around 20 lines.
Sample Input
ackermann(1,1)
Sample Output
3
nios/treedepthPrevious
Nextnios/findstack