Visit www.myprogramminglab.com to complete this Programming Challenge online and get instant feedback.
Ackermann’s Function
Ackermann’s function is a recursive mathematical algorithm that can be used to test how well a computer performs recursion. Write a method ackermann(m, n), which solves Ackermann’s function. Use the following logic in your method:
If m 5 0 then return n 1 1
If n 5 0 then return ackermann(m 2 1, 1)
Otherwise, return ackermann(m 2 1, ackermann(m, n 2 1))
Test your method in a program that displays the return values of the following method calls:
ackermann(0, 0) ackermann(0, 1) ackermann(1, 1) ackermann(1, 2)
ackermann(1, 3) ackermann(2, 2) ackermann(3, 2)