17 lines
522 B
Plaintext
17 lines
522 B
Plaintext
(defun hailstone (len)
|
|
(loop for x = len
|
|
then (if (evenp x)
|
|
(/ x 2)
|
|
(+ 1 (* 3 x)))
|
|
collect x until (= x 1)))
|
|
|
|
;; Must be tail recursive
|
|
(defun max-hailstone-start (limit mx curr)
|
|
(declare (xargs :mode :program))
|
|
(if (zp limit)
|
|
(mv mx curr)
|
|
(let ((new-mx (len (hailstone limit))))
|
|
(if (> new-mx mx)
|
|
(max-hailstone-start (1- limit) new-mx limit)
|
|
(max-hailstone-start (1- limit) mx curr)))))
|