I’m trying to solve the loop 3 test using while loop, but it seems I create an infinite loop accidentally, which I’m unable to find. Here is a link to my code.
It indicates an error in line 0 and I don’t understand.
I’m trying to solve the loop 3 test using while loop, but it seems I create an infinite loop accidentally, which I’m unable to find. Here is a link to my code.
It indicates an error in line 0 and I don’t understand.
I would like to help but I’m so sorry the request is above my knowledge
Hi @Selorm
continue
doesn’t mean “continue with this round of the loop” but “stop this round and continue with the next round”.
You need to remove the else
part of the condition. Otherwise the i--
will never be called when not a prime because of the continue
. The result is that the loop runs infinitely with the value 500.
Cheers,
Michael