[go: up one dir, main page]

Skip to content

Instantly share code, notes, and snippets.

@shandanjay
Created February 3, 2019 04:37
Show Gist options
  • Save shandanjay/9e036c8c68dc40225492054c12e0689b to your computer and use it in GitHub Desktop.
Save shandanjay/9e036c8c68dc40225492054c12e0689b to your computer and use it in GitHub Desktop.
A Multimethod solution to get the nth item in fibonacci series
(defmulti fibonacci identity)
(defmethod fibonacci 0 [_] 1)
(defmethod fibonacci 1 [_] 1)
(defmethod fibonacci :default [n] (+ (fibonacci (- n 1) ) (fibonacci (- n 2) )) )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment