Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- wl = [2,4,2,4,6,2,6,4,2,4,6,6,2,6,4,2,6,4,6,8,4,2,4,2,4,8,6,4,6,2,4,6,2,6,6,4,2,4,6,2,6,4,2,4,2,10,2,10]
- -- the so-called wheel: the recurring pattern in a composite punctuated list
- n7sl = scanl (+) 11 $ cycle wl -- infinite
- -- short list of composits with no 2's, 3's 5's or 7's; 77%+ reduced
- n7s = take 150 $ n7sl
- -- diagonalize and limit the factor's composite list
- lls i y = drop i.take y $ n7sl
- -- substract the 1st list from the 2nd, infinite list
- rms [] _ = [] -- stop when first list is exhausted
- rms n@(x:xs) p@(y:ys)
- | x==y = rms xs ys
- | x>y = y:rms n ys
- | y>x = rms xs p
- -- generate the composite list
- comps [] _ _ _ _ =[]
- comps (n:ns) [] y i b = comps ns (lls (i+1) y) y (i+1) b
- comps k@(n:ns) (r:rs) y i b
- | m>b =comps ns (lls (i+1) y) y (i+1) b
- | m<=b =m:comps k rs y i b
- where m = n*r
- -- the result of `comps` is not just a diagonalization but 2, top & irregular bottom
- -- `comps` is maybe necessary to stop when the limit of a list is reached
- -- otherwise, I was using a list comprehension which is way less complicated
- -- `comps` has to many parameters so this to reduce it to 1
- -- it will be subtracted the fixed length wheel numbers and the lazy wheel
- comp1 n =sort $ comps n7s (lls 0 n) n 0 (11*(last.take n $ n7sl))
- -- put everything together to generate primes
- comp1 y = sort [ m
- | (i,n) <- zip [0..149] n7sl
- , m <- takeWhile ((<= 11 * last (take y n7sl))) $ map (n*) $ drop i $ take n n7sl
- ]
- t = sort [ m | bs@(a:_) <- tails n7s,
- m <- takeWhile (<= 11*last n7s) $ map (a*) bs]
- calcc _ _ []= []
- calcc f lim (x:xs)
- | m<= lim= m:calcc f lim xs
- | True= []
- where m= f*x
- runr _ []= []
- runr lim xss@(x:xs) = (calcc x lim xss)++runr lim xs
- rrunr n = runr lim ds
- where ds= take n n7sl
- lim= 11*last ds
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement