Skip to content

Instantly share code, notes, and snippets.

@bitdewy
Created April 7, 2013 16:55
Show Gist options
  • Save bitdewy/5331290 to your computer and use it in GitHub Desktop.
Save bitdewy/5331290 to your computer and use it in GitHub Desktop.
Project Euler #2 in Common Lisp
;;;;
;;;; 2.lisp
;;;; ProjectEuler
;;;;
;;;; Created by bitdewy on 4/8/13.
;;;; Copyright (c) 2013 bitdewy. All rights reserved.
;;;;
;; Project Euler #2
(defun fibonacci (max)
"generate fibonacci sequence do not exceed max"
(do ((sequence nil) (cur 1 next) (next 2 (+ cur next)))
((> cur max) (reverse sequence))
(push cur sequence)))
(reduce #'+
(remove-if-not #'evenp (fibonacci 4000000)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment