September 2017
Beginner to intermediate
396 pages
9h 46m
English
primes :: [Integer] primes= 2 : filterMultiples allMultiples [3,5..] where allMultiples = mergeMultiples $ map multiples primes multiples i = map (i*) [i..]
Here, allMultiples are all multiples of all the primes; filterMultiples will weed out all those multiples from the list of odd numbers [3,5..]. All multiples are found out by lazily going over the primes that we are calculating and finding multiples of each.
Read now
Unlock full access