сито
internal class Program
{
public static void Main()
{
var n = 53;
var prime = SieveOfEratosthenes(n);
for (int i = 2; i <= n; i++)
{
if(prime[i] == 0)
{
Console.WriteLine(i); ;
}
}
}
public static int[] SieveOfEratosthenes(int num)
{
var isPrime = new int[num + 1];
for (int i = 2; i <= num; i++)
{
if (isPrime[i]==0)
{
for (int j = i * 2; j <= num; j += i)
{
// Eliminate multiples of i.
isPrime[j] = 1;
}
}
}
return isPrime;
}
}
PrashantUnity