using System.Collections.Generic;
using System.Collections.Concurrent;
using System.Threading.Tasks;
using System.Diagnostics;
Console.WriteLine($"Running on a {Environment.GetEnvironmentVariable("PROCESSOR_IDENTIFIER")}");
var sw = Stopwatch.StartNew();
var primes = FindPrimesInRange(2, 250_001);
Console.WriteLine(string.Join(", ", primes));
Console.WriteLine($"Elapsed time: {sw.Elapsed}");
static IEnumerable<int> FindPrimesInRange(int start, int end)
var bag = new ConcurrentBag<int>();
Parallel.For(start, end, i =>
static bool IsPrime(int n)
for (var i = 2; i <= boundary; i++)