Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- is_prime :: Integer -> Bool
- is_prime x = is_prime_iter x 2
- where
- is_prime_iter :: Integer -> Integer -> Bool
- is_prime_iter x y | 2*y > x = True
- | mod x y /= 0 = is_prime_iter x (y+1)
- | otherwise = False
- primeList :: Integer -> [Integer]
- primeList 0 = []
- primeList cnt = ghost cnt 2
- where
- ghost :: Integer -> Integer -> [Integer]
- ghost 0 lst = []
- ghost cnt lst | is_prime (lst) = lst : ghost (cnt-1) (lst+1)
- | otherwise = ghost cnt (lst+1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement