![[XANALYS]](../Graphics/XanSmall.gif)
![[Previous]](../Graphics/Prev.gif)
![[Up]](../Graphics/Up.gif)
![[Next]](../Graphics/Next.gif)
2.4.4.2.5 Examples of Style for Semicolon
;;;; Math Utilities
;;; FIB computes the the Fibonacci function in the traditional
;;; recursive way.
(defun fib (n)
(check-type n integer)
;; At this point we're sure we have an integer argument.
;; Now we can get down to some serious computation.
(cond ((< n 0)
;; Hey, this is just supposed to be a simple example.
;; Did you really expect me to handle the general case?
(error "FIB got ~D as an argument." n))
((< n 2) n) ;fib[0]=0 and fib[1]=1
;; The cheap cases didn't work.
;; Nothing more to do but recurse.
(t (+ (fib (- n 1)) ;The traditional formula
(fib (- n 2)))))) ; is fib[n-1]+fib[n-2].
![[Starting Points]](../Graphics/StartPts.gif)
![[Contents]](../Graphics/Contents.gif)
![[Index]](../Graphics/Index.gif)
![[Symbols]](../Graphics/Symbols.gif)
![[Glossary]](../Graphics/Glossary.gif)
![[Issues]](../Graphics/Issues.gif)
Copyright 1996-2001, Xanalys Inc. All rights reserved.