Skip to content

Instantly share code, notes, and snippets.

@katsuyan
Last active December 2, 2016 01:51
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/905db863922e15f3af34b20f4065159f to your computer and use it in GitHub Desktop.
Save katsuyan/905db863922e15f3af34b20f4065159f to your computer and use it in GitHub Desktop.
数学パズルonClojure-Q4
(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