Created
March 18, 2017 14:26
-
-
Save sw-samuraj/41a0e46e05298c3a941c98531ac81648 to your computer and use it in GitHub Desktop.
Counts a Catalan number through recursion.
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 catalan [n] | |
"Counts a Catalan number by recursion." | |
(loop [cnt n acc 1] | |
(if (zero? cnt) | |
acc | |
(recur (dec cnt) | |
(* acc (- 4 (/ 6 (inc cnt)))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment