finding first n semi-prime integers

HI, i am trying to find the first 2000,000 square free semi-prime numbers( mathWorld , oeis). I have generated the prime numbers but to get these semi-prime numbers i am trying as follows:

Code:

`int limit1 = 1000;`

int limit2 = 2000;

for(i=0;i<=limit1;i++)

{

for(j=i+1;j<=limit2;j++)

{

semiPrimes[size++]=(primes[i]*primes[j]);

}

limit2++;

}

however on chaging either limit1 or limit2 gives different values for semiprime[200000] . So what should be correct values of these variables?

Thanks.

Re: finding first n semi-prime integers

Your list is not in order.

You will get 6,10,14,22,26,..............,15,21,33,39,......... ...........35,55,65.......etc

Re: finding first n semi-prime integers

Quote:

Originally Posted by

**a tutor** Your list is not in order.

You will get 6,10,14,22,26,..............,15,21,33,39,......... ...........35,55,65.......etc

that i am managing by sorting the semiPrime array after going out of both loops