Skip to content

Instantly share code, notes, and snippets.

@tgallant
Created November 4, 2014 05:14
Show Gist options
  • Save tgallant/2c423ce2099f16f34a5e to your computer and use it in GitHub Desktop.
Save tgallant/2c423ce2099f16f34a5e to your computer and use it in GitHub Desktop.
euler2
;; 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