aboutsummaryrefslogtreecommitdiff
path: root/Math.hs
blob: ddeac3247c9b8cd6dc673811ac13eeb9dd247ac0 (plain)
1
2
3
4
5
6
7
8
9
module Math where
    isPrime :: Int -> Bool
    factors :: Int -> [Int]
    intersect' :: [Int] -> [Int] -> [Int]

    isPrime n = (length [ x | x <- [2..(ceiling $ sqrt $ fromIntegral 2)],
                                    n `mod` x == 0]) == 0
    factors n = [x | x <- [1..(n `div` 2)], n `mod` x == 0] ++ [n]
    intersect' a b = [x | x <- a, x `elem` b]