Primality by trial division: Difference between revisions

Content added Content deleted
Line 487:
 
===Segmented Generate and Test===
StartingExplicating the list of filters on each filtersegment nobetween soonerthe thanconsecutive squares of primes, as a list of factors to test by (so that no ittesting is actuallydone neededprematurely), and rearranging to avoid recalculations, leads to this:
<lang haskell>primes = 2 : 3 : sieve 5 9 (drop 2 primes) 0 where
sieve x q ps k = let fs = take k (tail primes) in