Skip to content

Instantly share code, notes, and snippets.

@katsuyan
Last active March 3, 2017 10:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save katsuyan/0dfb7c8643a855427abe22d6f0076c75 to your computer and use it in GitHub Desktop.
Save katsuyan/0dfb7c8643a855427abe22d6f0076c75 to your computer and use it in GitHub Desktop.
数学パズルonClojure-Q6
(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