using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
namespace test
{
class Program
{
static void Main(string[] args)
{
Prime p = new Prime(1000);
p.GetPrime();
p.Print();
}
}
public class Prime
{
public int max;
BitArray prime;
public Prime(int max)
{
this.max = max;
prime = new BitArray(max+1, false);
}
public void GetPrime()
{
for (int i = 2; i < max+1; i++)
{
if (i % 2 == 0)
prime.Set(i, true);
}
for (int i = 3; i <= Math.Sqrt(max); i += 2)
{
if (!prime[i])
{
for (int j = i + i; j < max + 1; j += i)
{
prime.Set(j, true);
}
}
}
}
public void Print()
{
for (int i = 3; i < max + 1; i++)
if (!prime[i])
Console.WriteLine(i);
}
}
}