Skip to content

Instantly share code, notes, and snippets.

@captainsafia
Created August 17, 2012 20:54
Show Gist options
  • Save captainsafia/3382552 to your computer and use it in GitHub Desktop.
Save captainsafia/3382552 to your computer and use it in GitHub Desktop.
Solution to Project Euler Problem 2 in Scheme
(define x 0)
(define y 1)
(define n 0)
(define sum 0)
(define (evenfibsum)
(set! n (+ x y))
(set! x y)
(set! y n)
(if (= (modulo n 2) 0) (set! sum (+ sum n)))
(if (<= n 4000000) (evenfibsum)) sum)
(print (evenfibsum))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment