Skip to content

Instantly share code, notes, and snippets.

@tgallant
Created November 4, 2014 05:29
Show Gist options
  • Save tgallant/a9589cf46a746bbb8fa3 to your computer and use it in GitHub Desktop.
Save tgallant/a9589cf46a746bbb8fa3 to your computer and use it in GitHub Desktop.
euler5
;; helpers
(define (sum l)
(if (null? l)
0
(+ (car l) (sum (cdr l)))))
(define (sqr x)
(* x x))
;; e5
(define (sum-of-sq x)
(sum (map sqr (cdr (iota x)))))
(define (sq-of-sum x)
(sqr (sum (cdr (iota x)))))
(define (e6 x)
(- (sq-of-sum x) (sum-of-sq x)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment