>> this code where it should stop as soon as one of the conditions has met
But the break just gets you out of the while loop when one of the two conditions is met. You need to add a test after the while loop to see if you broke out, in which case you can add another break do get out of the for-loop.
But within the while loop, here are your constants:
- N (is being tested, but not changing)
- Discard1value (is being tested, but not changing)
- isOK1, isOK2 (are being tested but not changing)
Within the for-loop, only one variable N changes.
If the first time you hit the if N... test, you have a false condition, then you will never break out - you will be in an infinite loop since all the variables in the if test are constant within the body of the if-statement.
if N == (Discard1value) || ((isOK1 && isOK2))
>> it's taking so long to run and it also didn't stop utill the end
Since you are not reporting an infinite loop, then one of the conditions in the if-test must be true the first time you hit it. If the isOK test true, then it remains true for all values of N.
I advise you to put a breakpoint at the if-test, and step through a few loops to better understand your two loops.