ProgrammingVery hardCodeforces-style · placement coding round

What is printed?

What is printed?
def ack(m, n):
    if m == 0:
        return n + 1
    if n == 0:
        return ack(m - 1, 1)
    return ack(m - 1, ack(m, n - 1))
print(ack(2, 3), ack(3, 2))
  1. A. 9 29
  2. B. 9 25
  3. C. 8 29
  4. D. 9 31

Correct answer: A. 9 29

ack(2, n) equals 2n + 3, which gives 9 for n = 3, and ack(3, n) equals 2^(n+3) - 3, which gives 29 for n = 2.

More Python Programming questions

Exams that ask this topic