Friday, January 27, 2012

Lisp Program to Print Fibonocci Series upto a user specified Limit

The following is a lisp program to print the Fibonacci series up to a user specified limit.

 (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

Which is the Best Photo Watermarking Software

Photo Theft is becoming more and more common in the web with the outburst of social websites like Facebook,Google Plus and Image sharing se...