Skip to content

Instantly share code, notes, and snippets.

@smeghead
Created October 17, 2011 12:34
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 smeghead/1292514 to your computer and use it in GitHub Desktop.
Save smeghead/1292514 to your computer and use it in GitHub Desktop.
(defn fib [n]
(cond
(< n 0) (throw (IllegalArgumentException. "fib argument must be plus number."))
(= n 1) 1
(= n 2) 1
:else (+ (fib (- n 2)) (fib (- n 1)))))
(loop [x 1]
(if (< x 10)
(do
(println (fib x))
(recur (inc x)))))
(print (fib -1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment