add task 1
This commit is contained in:
15
src/task1 - Multiples of 3 and 5.hs
Normal file
15
src/task1 - Multiples of 3 and 5.hs
Normal file
@@ -0,0 +1,15 @@
|
||||
import System.IO
|
||||
import Data.List
|
||||
|
||||
isDivisibleBy3 :: Int -> Bool
|
||||
isDivisibleBy3 n = mod n 3 == 0
|
||||
|
||||
isDivisibleBy5 :: Int -> Bool
|
||||
isDivisibleBy5 n = mod n 5 == 0
|
||||
|
||||
isDivisibleBy3Or5 :: Int -> Bool
|
||||
isDivisibleBy3Or5 n = isDivisibleBy3 n || isDivisibleBy5 n
|
||||
|
||||
main = do
|
||||
let numbersDivisibleBy3Or5 = filter isDivisibleBy3Or5 [1..1000]
|
||||
putStrLn $ show $ sum numbersDivisibleBy3Or5
|
Reference in New Issue
Block a user