Sha256: 07707d24a4493ef9ee10beed7636f081fc4f89f9f173b37c4722e3be6b5e9040
Contents?: true
Size: 346 Bytes
Versions: 145
Compression:
Stored size: 346 Bytes
Contents
(defpackage #:collatz-conjecture (:use #:common-lisp) (:export #:collatz)) (in-package #:collatz-conjecture) (defun collatz-helper (a n) (cond ((= n 1) a) ((evenp n) (collatz-helper (+ 1 a) (floor n 2))) (T (collatz-helper (+ 1 a) (+ 1 (* 3 n)))))) (defun collatz (n) (when (> n 0) (collatz-helper 0 n)))
Version data entries
145 entries across 145 versions & 1 rubygems