Skip to content

Instantly share code, notes, and snippets.

@Daenyth
Created July 22, 2010 03:55
Show Gist options
  • Save Daenyth/485549 to your computer and use it in GitHub Desktop.
Save Daenyth/485549 to your computer and use it in GitHub Desktop.
import IO
wanted :: (Integral a) => a -> Bool
wanted x
| mod 3 x == 0 = True
| mod 5 x == 0 = True
| otherwise = False
problem1 :: (Integral a) => a -> a
problem1 x = sum $ filter wanted [1 .. x]
main = do
let answer = show $ problem1 1000 in putStrLn answer
-- prints 9 :(
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment