Created
January 17, 2015 18:46
-
-
Save IrakliJani/6ab161372414b8c11b29 to your computer and use it in GitHub Desktop.
Haskell Code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
factors :: Int -> [Int] | |
factors n = | |
[x | x <- [1..n], n `mod` x == 0] | |
factors 72 | |
out> [1,2,3,4,6,8,9,12,18,24,36,72] | |
prime :: Int -> Bool | |
prime n = factors n == [1, n] | |
prime 71 | |
out> True | |
primes :: Int -> [Int] | |
primes n = [x | x <- [2..n], prime x] | |
primes 71 | |
out> [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment