3 ms·
It looks much more functional if you get familiar with LINQ. var allPossibleNumbers = Enumerable.Range(3, max-3); var possiblePrime = allPossibleNumber
by pjc50 7y ago
It looks much more functional if you get familiar with LINQ.
var allPossibleNumbers = Enumerable.Range(3, max-3);
var possiblePrime = allPossibleNumbers
.AsParallel()
.Where(n => Enumerable.Range(2, (int)Math.Sqrt(n))
.All(i => n % i != 0)
);
(from https://codereview.stackexchange.com/questions/6115/sieve-of-eratosthenes-in-c-with-linq https://codereview.stackexchange.com/questions/6115/sieve-of... )