Skip to content

Instantly share code, notes, and snippets.

@tizoc
Created November 20, 2010 16:31
Show Gist options
  • Select an option

  • Save tizoc/707941 to your computer and use it in GitHub Desktop.

Select an option

Save tizoc/707941 to your computer and use it in GitHub Desktop.
;; def m(n, l)
;; t = 0
;; u = n
;; while u < l
;; t = t + u
;; u = u + n
;; end
;;
;; t
;; end
(define (m n l)
(let loop ((t 0) (u n))
(if (< u l)
(loop (+ t u) (+ u n))
t)))
;; def sm(a, b, l)
;; c = a * b
;; m(a, l) + m(b, l) - m(c, l)
;; end
(define (sm a b l)
(let ((c (* a b)))
(- (+ (m a l) (m b l))
(m c l))))
;; def euler1
;; sm(3, 5, 10000)
;; end
(define (euler1)
(sm 3 5 10000))
;; puts euler1
(display (euler1))
(newline)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment