0
編寫一個函數isPrime,確定整數是否是素數(均勻地 只能由它自己和一個整除)。作爲參考,這裏列出的質數小於100: [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] 什麼是第1000到第1020個素數? (在2開始)找到素數從2開始Haskell
isPrime :: [Integer]
isPrime = sieve [2..1020]
where
sieve (p:xs)
| p*p <= 1020 = p : sieve [x|x <- xs, x `mod` p > 0]
| otherwise = (p:xs)
我嘗試這樣的代碼,但它通過1020 我要顯示1000到1020以2