All pastes #1213739 Raw Edit

Anonymous

public text v1 · immutable
#1213739 ·published 2008-09-29 16:18 UTC
rendered paste body
minN = 8140000000
maxN = 8149999999

main = mapM print foundPrimes

foundPrimes :: [Integer]
foundPrimes = filter (\n -> all (not . divides n) shortPrimes) [minN..maxN]

shortPrimes :: [Integer]
shortPrimes = takeWhile (\x -> x*x < maxN) primes

primes :: [Integer]
primes = 2 : 3 : primes'
  where
    1 : p : candidates = [6*k+r | k <- [0..], r <- [1,5]]
    primes'            = p : filter isPrime candidates
    isPrime n          = all (not . divides n) $ takeWhile (\p -> p*p <= n) primes'

divides n p        = n `mod` p == 0