Advertisement
banovski

Primes up to 120

Oct 22nd, 2024
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Haskell 0.42 KB | Source Code | 0 0
  1. dropDivisibleBy :: Int -> Int -> [Int]
  2. dropDivisibleBy divisor dividend
  3.   | mod dividend divisor /= 0 || dividend == divisor = [dividend]
  4.   | otherwise = []
  5.  
  6. primes :: [Int]
  7. primes =
  8.   [2 .. 120] >>= dropDivisibleBy 2 >>= dropDivisibleBy 3 >>= dropDivisibleBy 5 >>= dropDivisibleBy 7
  9.  
  10. main :: IO ()
  11. main = print primes
  12.  
  13. -- [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113]
  14.  
Tags: primes
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement