Last active
December 2, 2016 01:51
-
-
Save katsuyan/905db863922e15f3af34b20f4065159f to your computer and use it in GitHub Desktop.
数学パズルonClojure-Q4
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
(defn cutbar-rec [m n current-num] | |
(cond | |
(>= current-num n) 0 | |
(< current-num m) (inc (cutbar-rec m n (* 2 current-num))) | |
:else (inc (cutbar-rec m n (+ current-num m))))) | |
(defn cutbar [m n] | |
(cutbar-rec m n 1)) | |
(def answer-1 (cutbar 3 20)) | |
(def answer-2 (cutbar 5 100)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment