Last active
March 3, 2017 10:33
-
-
Save katsuyan/0dfb7c8643a855427abe22d6f0076c75 to your computer and use it in GitHub Desktop.
数学パズルonClojure-Q6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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