1 #!/usr/bin/python3
 2 
 3 """ Just some mathonerdy nonsense. The ackermann-function is killing _every_ computer. Even yours. """
 4 
 5 import signal, sys
 6 
 7 
 8 def sigint_handler(signum, frame):
 9     sys.exit("\nOk, machen wir Feierabend...\n")
10 
11 
12 sys.setrecursionlimit(65535)
13 signal.signal(signal.SIGINT, sigint_handler)
14 clearscreen = "\x1b[2J\x1b[H"
15 outermax = 6
16 innermax = 6
17 
18 
19 # def ack(m, n):
20 #     if m == 0:
21 #         ans = n + 1
22 #     elif n == 0:
23 #         ans = ack(m - 1, 1)
24 #     else:
25 #         ans = ack(m - 1, ack(m, n - 1))
26 #     return ans
27 
28 
29 def ack(m, n):
30     if m == 0:
31         return n + 1
32     if n == 0:
33         return ack(m - 1, 1)
34     return ack(m - 1, ack(m, n - 1))
35 
36 
37 print(clearscreen)
38 
39 for outer in range(0, outermax, 1):
40     for inner in range(0, innermax, 1):
41         print("outer=", outer, " inner=", inner, end="")
42         print(" Die Antwort=", ack(outer, inner))