aboutsummaryrefslogtreecommitdiff
path: root/Math.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Math.hs')
-rw-r--r--Math.hs12
1 files changed, 12 insertions, 0 deletions
diff --git a/Math.hs b/Math.hs
new file mode 100644
index 0000000..b1eac91
--- /dev/null
+++ b/Math.hs
@@ -0,0 +1,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]