(defun fib (n) (labels ((rec (a b c p q) (cond ((zerop c) b) ((evenp c) (rec a b (floor c 2) (+ (* p p) (* q q)) (+ (* 2 p q) (* q q)))) (t (rec (+ (* b q) (* a q) (* a p)) (+ (* b p) (* a q)) (1- c) p q))))) (rec 1 0 n 0 1))) (defun main (&rest argv) (declare (ignorable argv)) (format t "~d~%" (fib (1+ (read))))) (main)