> but anything past that, it will output everything correctly as far I can tell
no, if the condition in line 24 fails then the one ine line 26 would succeed, always.
what's more, either path woud terminate the loop.
`div' would no go farther than 4, you only test against 2, 3, 4, 5, and 7.
Review the conditions for a number to be prime.
Also, to simplify the code, create a function
bool is_prime(int number)
then you may do
1 2 3
|
for(int number = start; number <= finish; ++number)
if( is_prime(number) )
std::cout << number << ' ';
|