DEV Community

Discussion on: Challenge: Write the recursive Fibonacci algorithm in a different language.

Collapse
 
gypsydave5 profile image
David Wickes • Edited

Common Lisp!

(defun fib (n &optional (curr 0) (next 1)) 
  (if (zerop n) 
      curr 
      (fib (1- n) next (+ curr next))))

(and for the TCO crowd... it's implementation dependent, so YMMV)