solution to problem 002 in lisp

master
Evan Hemsley 2016-10-19 11:33:42 -07:00
parent 57eb8dab59
commit 60b398489b
1 changed files with 11 additions and 0 deletions

11
lisp/euler002.lisp Normal file
View File

@ -0,0 +1,11 @@
(load "euler.lisp")
(defun fibonacci-list-helper (n builder)
(if (>= (+ (first builder) (first (rest builder))) n) builder (fibonacci-list-helper n (cons (+ (first builder) (first (rest builder))) builder)))
)
(defun fibonacci-list (n)
(fibonacci-list-helper n (list 2 1))
)
(defun solution () (sum (select (lambda (a) (eq (mod a 2) 0)) (fibonacci-list 4000000))))