Skip to content

Instantly share code, notes, and snippets.

@kkirsanov
Created May 29, 2012 12:50
Show Gist options
  • Select an option

  • Save kkirsanov/2828212 to your computer and use it in GitHub Desktop.

Select an option

Save kkirsanov/2828212 to your computer and use it in GitHub Desktop.
euler 1
--If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
--Find the sum of all the multiples of 3 or 5 below 1000.
mapf fs x = map ($ x) fs
mod' x = (0==) . flip mod x
mods = [3, 5]
lst = [1..999]
flt = filter f lst where
f x = or $ mapf (map mod' mods) x
s = sum flt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment