"""==========================
exercise 6.5
=========================="""
def ack(m,n):
if (m < 0) or (n < 0):
print ("positive integers only please")
return
elif not (isinstance(m, int) and isinstance(n, int)):
print ("positive integers only please")
return
elif m == 0:
return n+1
elif (m > 0) and (n == 0):
result = ack(m-1, 1)
return result
elif (m > 0) and (n >0):
result = ack(m-1, ack(m,n-1))
return result
print (ack(3,4))
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.