aboutsummaryrefslogtreecommitdiff
path: root/Math.hs
blob: b1eac91c861421fb807399d3132a1ffc6b2509cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
module Math where
    isPrime :: Int -> Bool

    isPrime n = (length [ x | x <- [2..(ceiling $ sqrt $ fromIntegral 2)],
                                    n `mod` x == 0]) == 0

    factors :: Int -> [Int]

    factors n = [x | x <- [1..(n `div` 2)], n `mod` x == 0] ++ [n]

    intersect' :: [Int] -> [Int] -> [Int]
    intersect' a b = [x | x <- a, x `elem` b]