/ Published in: C#
![](/img/icon_sav.png?v3)
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
static List<int> findPrimes(int max) { var maxSquareRoot = Math.Sqrt(max); vals.Add(2); for (int i = 3; i <= max; i += 2) { if (!eliminated[i]) { if (i < maxSquareRoot) { for (int j = i * i; j <= max; j += 2 * i) eliminated[j] = true; } vals.Add(i); } } return vals; }
Comments
![RSS Feed for Comments RSS Icon](/images/rss.png?v3)