Created
November 4, 2014 05:14
-
-
Save tgallant/2c423ce2099f16f34a5e to your computer and use it in GitHub Desktop.
euler2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; helpers | |
(define (sum l) | |
(if (null? l) | |
0 | |
(+ (car l) (sum (cdr l))))) | |
;; e2 | |
(define (fib x) | |
(define (fib-inner n) | |
(if (<= n 2) 1 | |
(+ (fib-inner (- n 1)) (fib-inner (- n 2))))) | |
(define (fib-list num) | |
(let ((i (fib-inner num))) | |
(if (> i x) | |
'() | |
(cons i (fib-list (+ num 1)))))) | |
(sum (filter even? (fib-list 1)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment