Skip to content

Instantly share code, notes, and snippets.

@richhickey
Created June 16, 2010 03:11
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save richhickey/440102 to your computer and use it in GitHub Desktop.
;new num branch results
(defn fib [n]
(if (>= 1 n)
1
(+ (fib (dec n)) (fib (- n 2)))))
(time (fib 38))
"Elapsed time: 3716.828 msecs"
;note, no change to body
(defn ^:static fib ^long [^long n]
(if (>= 1 n)
1
(+ (fib (dec n)) (fib (- n 2)))))
(time (fib 38))
"Elapsed time: 380.448 msecs"
@berlinbrown
Copy link

Could you explain the syntax is that new?

@gnuvince
Copy link

Greater than or equal? Shouldn't it be less than or equal?

@gnuvince
Copy link

Durrr, nevermind, you inverted the condition. Ignore me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment