multiples_of_3_5.gsp 453 B

12345678910111213141516
  1. (ns main
  2. "fmt"
  3. "github.com/jcla1/gisp/core")
  4. (def main (fn []
  5. (fmt/println (sum-of-multiples 1000))))
  6. (def sum-of-multiples (fn [below]
  7. (loop [[below (+ -1 below)]
  8. [sum 0.0]]
  9. (if (= below 0)
  10. sum
  11. (let [[n (+ -1 below)]]
  12. (if (or (= 0 (mod below 3)) (= 0 (mod below 5)))
  13. (recur n (+ sum below 1)))
  14. (recur n sum))))))