Advertisement
triclops200

O(n) recursive Fibonacci

Sep 18th, 2012
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scheme 0.24 KB | None | 0 0
  1. (define fib (lambda (n) (fib_h 1 0 n )))
  2. (define fib_h (lambda (a b d)  
  3.     (cond
  4.         ((= d 1)
  5.             (+ a b)
  6.         )  
  7.         (#t
  8.             (fib_h b (+ a b) (- d 1))
  9.         )  
  10.     )  
  11. ))
  12. (display (fib 500000))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement