ProgrammingVery hardGATE CS · Campus placements

The Ackermann function is defined as A(0,n) = n+1, A(m,0) = A(m-1,1), and A(m,n) = A(m-1, A(m,n-1)) for m, n > 0. What is A(2,3)?

  1. A. 7
  2. B. 5
  3. C. 11
  4. D. 9

Correct answer: D. 9

A(1,n) = n+2 and A(2,n) = 2n+3, so A(2,3) = 9. The nested recursion is why such functions are a classic test of call-stack depth.

More C Programming questions

Exams that ask this topic