C# Trying to avoid duplicates
c#, linq
Solution
You can use `Any()` instead of a full Cartesian join:
var multiples = from i in Enumerable.Range(min, (max - min))
where roots.Any(r => i % r == 0)
select i;
This has the added advantage that it will stop testing elements in `roots` as soon as it finds one that succeeds, and it does not require a second pass through to pull out the distinct elements.
Problem
``` var multiples = from i in Enumerable.Range(min, (max - min)) from r in roots where i % r == 0 select i; ``` For example, if `roots = {2,10}` it would select `20` twice. Is it possible to avoid duplicates here?