Login
7 branches 0 tags
Ben (X13/Arch) Simplified things a little 0643405 9 days ago 1260 Commits
nujel / tests / fast / euler001.nuj
#!/usr/bin/env nujel
; Multiples of 3 or 5
; https://projecteuler.net/problem=1
;
; Find the sum of all the multiples of 3 or 5 below 1000.

(defn multiple-of-3? (α)
       (zero? (rem α 3)))

(defn multiple-of-5? (α)
       (zero? (rem α 5)))

(defn multiple-of-3-or-5? (α)
       (or (multiple-of-3? α)
           (multiple-of-5? α)))

(def result (-> (range 1000)
                (filter multiple-of-3-or-5?)
                (sum)))
(when (not= result 233168)
      (throw (list :wrong-result "Wrong result" result)))
(return :success)