Need help correcting my code for calculating sexy prime pairs

So I have been given a problem in class stating that I had to calculate the sexy prime pairs. I have to use the sieve of eratosthenes alogorithm and a array to calculate the prime numbers and then use that same array to display the sexy prime pairs in between boundaries that are specified by the user. Much help will be appreciated thanks.

This is the sample run.

Please enter a lower boundary and an upper boundary and I will print all of the

sexy prime pairs between those boundaries.

Please enter the lower boundary (between 1 and 50000): 0

Please enter the lower boundary (between 1 and 50000): 50001

Please enter the lower boundary (between 1 and 50000): 150

Please enter the upper boundary (between 1 and 50000): 0

Please enter the upper boundary (between 1 and 50000): 50001

Please enter the upper boundary (between 1 and 50000): 100

Your upper boundary cannot be smaller than your lower boundary

Please enter the lower boundary (between 1 and 50000): 8997

Please enter the upper boundary (between 1 and 50000): 9200

Here are all of the sexy prime pairs in the range 8997 to 9200, one pair per line:

9001 and 9007

9007 and 9013

9043 and 9049

9103 and 9109

9127 and 9133

9151 and 9157

9181 and 9187

There were 7 sexy prime pairs displayed between 8997 and 9200.

Re: Need help correcting my code for calculating sexy prime pairs

Any chance you could explain what your problem is and ask a specific question?

Re: Need help correcting my code for calculating sexy prime pairs

Code :

for (int e = 2; e <= 223; e++)
{
if (primes[e])
{
for (int f = e; f <= 223; f++)
{
int g = (e * f);
primes[g] = true;
}
}
}

And

Code :

int g = (e * f);
primes[g] = true;

What do you expecting it to do?

Let's say e=5 and f = 10, so?

I have looked on your code. A real immature approach. May be with some fixes it will lead you to the solution but in the end, not efficient enough.

Re: Need help correcting my code for calculating sexy prime pairs

My major problem is calculating the prime numbers using the sieve of eratosthenes algorithm. How do I Loop through the factors and mark them like and unmark them if they are prime?

Re: Need help correcting my code for calculating sexy prime pairs

My problems are the prime number algorithm and my sexy prime pairs im a little unsure as to how to calculate them and I understand my attempts to do so have not been very good.

Re: Need help correcting my code for calculating sexy prime pairs

I will recommend you to take a pencil and a paper and draw, how will you do it manually.

Write all the steps and then code them.