fibonacci.el 322 B

12345678910111213141516
  1. #!/usr/bin/emacs --script
  2. (setq fibonacciCalls 0)
  3. (defun fibonacci (n)
  4. "generate the nth fibonacci number"
  5. (setq fibonacciCalls (+ 1 fibonacciCalls))
  6. (cond
  7. ((eq n 0) nil)
  8. ((eq n 1) 0)
  9. ((eq n 2) 1)
  10. ((+ (fibonacci (- n 1)) (fibonacci (- n 2)) ))))
  11. (princ (fibonacci 3))
  12. (princ fibonacciCalls)
  13. (print "")