in reply to
Re^2: Challenge: Another Infinite Lazy List
in thread Challenge: Another Infinite Lazy List
The two approaches are not the same at all. Say there are N numbers and R prime factors. The merge methods use:
N*(1/p1 + 1/p2 + ... 1/pR)*(R-1)
comparison operations to process a list of size N.
The filter method tests each number with a single gcd calculation, which is O(logN) and is independent of the total number of factors. So to produce a list of size N should be O(NlogN).
Depending on the size and quantity of factors, one or the other will be better. I would expect the filter to be better when there are many small factors, and the merge to be better when there are few factors or the factors are large.