- Open src/Main.hs; we will add our prime number generator here.
- We will start with 2 as the initial prime number and continue with only odd numbers; this will remove all the factors of 2.
- We will assume that there are infinite prime numbers. We can write a list of primes as follows:
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.
- We need to implement filterMultiples ...