The following is a lisp program to print the Fibonacci series up to a user specified limit.
The folowing program produces the Output
OUTPUT
Enter the limit : 8
Fibonacci Series : 0 1 1 2 3 5 8 13
(defun fibonacci()
(format t "Enter the limit : ")
(setf n(read))
(format t "Fibonacci Series : ")
(format t "0 1")
(setf a 0)
(setf b 1)
(do ((i 3(+ i 1))) ((> i n))
(setf c (+ a b))
(format t " ~d" c)
(setf a b)
(setf b c)))
The folowing program produces the Output
OUTPUT
Enter the limit : 8
Fibonacci Series : 0 1 1 2 3 5 8 13
No comments:
Post a Comment