Skip to content

Instantly share code, notes, and snippets.

@corehello
Last active December 14, 2019 12:41
Show Gist options
  • Save corehello/4d0171f1147c25ea0f4037843927b6d6 to your computer and use it in GitHub Desktop.
Save corehello/4d0171f1147c25ea0f4037843927b6d6 to your computer and use it in GitHub Desktop.
collatz-conjecture in common lisp
(defun collatz-conjecture (n)
(progn
(print n)
(cond
((= n 1) n)
((= (mod n 2) 0) (collatz-conjecture (/ n 2)))
((= (mod n 2) 1) (collatz-conjecture (+ 1 (* n 3)))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment