#B2144. Ackermann Function Evaluation
Ackermann Function Evaluation
Ackermann Function Evaluation
This problem asks you to evaluate the Ackermann function \( A(m, n) \) for given non-negative integers \(m\) and \(n\). The function is defined by:
\( A(m, n) = n + 1 \) (if \( m = 0 \));
\( A(m, n) = A(m-1, 1) \) (if \( m > 0 \) and \( n = 0 \));
\( A(m, n) = A(m-1, A(m, n-1)) \) (if \( m > 0 \) and \( n > 0 \)).
Constraints: \( m \) and \( n \) are non-negative integers. It is guaranteed that \( m \le 3 \) and \( n \le 10 \).
inputFormat
The input consists of two space-separated integers \( m \) and \( n \).
outputFormat
Output the value of the Ackermann function \( A(m, n) \) computed using the above recursive definition.
sample
0 5
6