Sha256: cf89953982df69d71a9bc4ecbf9f480b72f352621c0a3d5fa0fe26f287428e8c
Contents?: true
Size: 348 Bytes
Versions: 145
Compression:
Stored size: 348 Bytes
Contents
(ns collatz-conjecture) (defn collatz-helper [n] (cond (= 1 n) 1 (even? n) (/ n 2) :else (inc (* 3 n)))) (defn collatz [n] (if (> n 0) (count (take-while #(not= 1 %) (iterate collatz-helper n))) (throw (IllegalArgumentException. "Just defined for numbers greater than 0."))))
Version data entries
145 entries across 145 versions & 1 rubygems