Skip to content

Instantly share code, notes, and snippets.

@zacstewart
Created July 6, 2013 18:16
Show Gist options
  • Save zacstewart/5940734 to your computer and use it in GitHub Desktop.
Save zacstewart/5940734 to your computer and use it in GitHub Desktop.
#lang racket
(define (sum-of-multiples-of a b n)
(define (iter acc n)
(if (= n 0)
acc
(iter
(+ acc (if (or (= (modulo n a) 0) (= (modulo n b) 0)) n 0))
(- n 1))))
(iter 0 (- n 1)))
(sum-of-multiples-of 3 5 1000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment