100.0% (61/61)

72.5% (87/120)

# Description

In mathematics, ackermann function is a special kind of recursive function that is not primitive recursive,
which means that you can not re-write the function into iterative form.
Below is the definition of ackermann function:

A(n, m) = \begin{align} \begin{cases} m + 1 & \textrm{ , if n = 0} \\ A(n - 1, 1) & \textrm{ , if m = 0} \\ A(n - 1, A(n, m - 1)) & \textrm{ , otherwise} \\ \end{cases} \end{align}

Given n and m, please write a program to calculate the value of $A(n, m)$.

# Input Format

two integers $n$ and $m$ ($0 \leq n \leq 3$, $0 \leq m \leq 10$), separated by a space

# Output Format

an integer which represents $A(n, m)$

2 3

9