; solves the collatz conjecture ; return one step in the sequence (define (collatz-step n) (if (even? n) (/ n 2) (+ 1 (* 3 n)))) ; recurse over all numbers (define (collatz n) (if (= n 1) (displayln "All done!") (begin (display "N = ") (displayln n) (collatz (collatz-step n))))) ; get input and run it (displayln "Enter a positive number:") (collatz (read))