(defconstant +keta+ (make-array 19 :initial-contents '(1 10 100 1000 10000 100000 1000000 10000000 100000000 1000000000 10000000000 100000000000 1000000000000 10000000000000 100000000000000 1000000000000000 10000000000000000 100000000000000000 1000000000000000000))) (defun gen-pell-solver () (let ((x 7) (y 5)) (labels ((next () (let ((result (cons x y)) (xx x) (yy y)) (setq x (+ (* 3 xx) (* 4 yy)) y (+ (* 2 xx) (* 3 yy))) result))) (lambda () (next))))) (defun main (&rest argv) (declare (ignorable argv)) (let* ((x (1- (read))) (gen (gen-pell-solver))) (dotimes (_ 23) (let ((a+b.c (funcall gen))) (when (>= (cdr a+b.c) (aref +keta+ x)) (format t "~d ~d ~d~%" (floor (car a+b.c) 2) (ceiling (car a+b.c) 2) (cdr a+b.c)) (return-from main)))))) (main)