99-haskell-problems/Problems 31-41/problem_39.hs

9 lines
250 B
Haskell
Raw Normal View History

2024-05-26 01:13:00 -05:00
isqrt :: (Integral n) => n -> n
isqrt = floor . sqrt . fromIntegral
isPrime :: (Integral n) => n -> Bool
isPrime n = (n >= 2) && all ((/= 0) . (n `mod`)) [2 .. isqrt n]
primesR :: (Integral n) => n -> n -> [n]
primesR m n = filter isPrime [m .. n]