; Fibonacci + Ackermann — the classic recursion duo.
; Tests deep recursion across all three tiers.

(define (fib n)
  (if (< n 2) n
      (+ (fib (- n 1)) (fib (- n 2)))))

(define (ack m n)
  (cond ((= m 0) (+ n 1))
        ((= n 0) (ack (- m 1) 1))
        (else    (ack (- m 1) (ack m (- n 1))))))

; Demo deliberately stays small so Pyodide finishes in a few seconds.
; (ack 3 4) is 125 but takes minutes via CPython-in-WASM tree-walker;
; cut down to (ack 3 3) so every tier can run it.
(display "fib(15) = ")  (print (fib 15))
(display "fib(20) = ")  (print (fib 20))
(display "ack(2,3) = ") (print (ack 2 3))
(display "ack(3,3) = ") (print (ack 3 3))
(print "done")
