Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- """
- def func_rec(M, N):
- """
- recursion func which describe function Anckerman
- M, N : input values in func
- """
- assert (M >= 0 and N >= 0), 'M and N is equal or greater than zero'
- if M == 0:
- return (N + 1)
- elif M > 0 and N == 0:
- return func_rec(M-1, 1)
- elif M > 0 and N > 0:
- return func_rec(M-1, func_rec(M, N-1))
- def main_func():
- """
- main funct to entry recursion func
- """
- M = int(input('M_val -->: '))
- N = int(input('N_val -->: '))
- assert (M <= 3 and N <= 3), 'input M and N is equal or less than 3 due to complexity'
- res = func_rec(M, N) # result of func
- print(res)
- if __name__ == "__main__":
- main_func()
Advertisement
Add Comment
Please, Sign In to add comment