long limit,sqrLimit,i,j,n;
long[] A = new long[1001];
limit = 1000;
sqrLimit = Convert.ToInt64(Math.Sqrt(1000));
for (i = 0; i <= limit; i++)
A[i] = 0;
for (i = 2; i <= sqrLimit + 1; i++)
for (j = i + i; j <= limit; j = j + i)
A[j] = 1;
n = 0;
for (i = 2; i <= limit; i++)
if (A[i] == 0)
{
A[n] = i;
n++;
}