using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Alg; class Program // O(n^2) { static void Main(string[] args) { int n1 = Convert.ToInt32(Console.ReadLine()); FindPrimes(n1); } static void FindPrimes(int n) { bool[] isPrime = new bool[n + 1]; for (int i = 2; i <= n; i++) { isPrime[i] = true; } for (int i = 2; i <= n; i++) { if (isPrime[i] == true) { Console.Write(i + " "); for (int j = i * i; j <= n; j += i) { isPrime[j] = false; } } } } }