factors :: Int -> [Int] factors n = [m | m <- [1 .. n], n `mod` m == 0] prime :: Int -> Bool prime n = factors n == [1,n] primes :: Int -> [Int] primes n = [p | p <- [1 .. n], prime p]