Finding all prime numbers between two numbers
So I have to input two numbers between 4 and 1 million and find out all the prime numbers between the two but I need some help...
Here is the computational part, if you could let me know how to get it right, that would be great!
The code keeps outputting numbers like 9 and 15, which I don't want
for (int i = b; i <= a; i++)
for (int j = 2; j <= sqrt(i); j++)
if (i%j != 0 && i%2 != 0)
cout << i << " is prime" << endl;
Last edited on
Topic archived. No new replies allowed.