https://zhidao.baidu.com/question/758417906051140284.html
using System;
using System.Collections.Generic;
using System.Linq;
class Test
{
static void Main()
{
int[] array = num(1000, 10000).ToArray();
Console.WriteLine("Count: {0}", array.Length);
foreach (int num in array)
Console.Write(num + " ");
Console.WriteLine();
}
// https://stackoverflow.com/a/1510186/9606292
static IEnumerable<int> num(int m, int n) =>
Enumerable.Range(0, (int)Math.Floor(2.52 * Math.Sqrt(n) / Math.Log(n))).Aggregate(
Enumerable.Range(2, n - 1).ToList(),
(result, index) =>
{
var bp = result[index]; var sqr = bp * bp;
result.RemoveAll(i => i >= sqr && i % bp == 0);
return result;
}
).Where(x => x > m);
}