Create a gist now

Instantly share code, notes, and snippets.

@katsuyan /q6.clj
Last active Mar 3, 2017

What would you like to do?
(ns puzzule.q6)
(defn check-recur [n start]
(cond (= n start) true
(= n 1) false
:else (if (even? n)
(recur (/ n 2) start)
(recur (+ (* n 3) 1) start))))
(defn check [n]
(check-recur (+ (* n 3) 1) n))
(defn get-answer [n]
(let [even-nums (range 2 (+ n 1) 2)]
(count (filter check even-nums))))
(def answer (get-answer 10000))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment