# finding first n semi-prime integers

• Apr 27th 2012, 10:40 AM
pranay
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.
• Apr 27th 2012, 10:52 AM
a tutor
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
• Apr 27th 2012, 06:51 PM
pranay
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