diff options
author | Aryadev Chavali <aryadev@aryadevchavali.com> | 2021-06-26 14:37:28 +0100 |
---|---|---|
committer | Aryadev Chavali <aryadev@aryadevchavali.com> | 2021-06-26 14:37:28 +0100 |
commit | 4a781087c9520ecb700f0f557960e0e0de461a4d (patch) | |
tree | 733bee80a76c1bcf435c43735e525648652fe8f9 /Math.hs | |
parent | f82f9831b1a4773f0a47c6daf176b63da82aa962 (diff) | |
download | numberdisplay-4a781087c9520ecb700f0f557960e0e0de461a4d.tar.gz numberdisplay-4a781087c9520ecb700f0f557960e0e0de461a4d.tar.bz2 numberdisplay-4a781087c9520ecb700f0f557960e0e0de461a4d.zip |
(Code)+math module that holds all my mathematical functions
Diffstat (limited to 'Math.hs')
-rw-r--r-- | Math.hs | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -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] |