Fibonacci numbers in Lisp
Example for versions
JScheme 7.2,
MIT/GNU Scheme 7.7.9,
guile 1.8.5
This example uses recursive definition of Fibonacci numbers.
(define (fibonacci x)
(if (< x 2)
x
(+ (fibonacci (- x 1)) (fibonacci (- x 2)))))
(do ((i 1 (+ i 1)))
((> i 16))
(display (string-append (number->string (fibonacci i)) ", ")))
(display "...")
(newline)
Comments
]]>blog comments powered by Disqus
]]>