fork download
  1. namespace HomeAlone
  2. {
  3. internal class Program
  4. {
  5. static void Main(string[] args)
  6. {
  7. int n = 5000000;
  8. int cnt = 0;
  9. bool[] primes = new bool[n + 1];
  10.  
  11. for (int i = 2; i < n; i++)
  12. {
  13. if (primes[i] == true) continue;
  14. else
  15. {
  16. cnt++;
  17. int temp = i + i;
  18. while (temp < n)
  19. {
  20. primes[temp] = true;
  21. temp += i;
  22. }
  23. }
  24. }
  25. Console.WriteLine(cnt);
  26. }
  27. }
  28. }
  29.  
Success #stdin #stdout 0.15s 35632KB
stdin
Standard input is empty
stdout
348513