main.lisp 389 B

12345678910111213141516171819
  1. (defun new-next-fibo-generator ()
  2. (let ((x0 0)
  3. (x1 1))
  4. (lambda ()
  5. (let ((next (+ x0 x1)))
  6. (setf x0 x1)
  7. (setf x1 next)
  8. next))))
  9. (defvar *uplimit* 4000000)
  10. (let ((next-fibo (new-next-fibo-generator))
  11. (sum 0))
  12. (do ((x (funcall next-fibo) (funcall next-fibo)))
  13. ((> x *uplimit*) sum)
  14. (setf sum (if (evenp x)
  15. (+ sum x)
  16. sum)))
  17. (format t "~&~S" sum))