namespace HomeAlone { internal class Program { static void Main(string[] args) { int n = 5000000; int cnt = 0; bool[] primes = new bool[n + 1]; for (int i = 2; i < n; i++) { if (primes[i] == true) continue; else { cnt++; int temp = i + i; while (temp < n) { primes[temp] = true; temp += i; } } } Console.WriteLine(cnt); } } }