Your code is decrementing
x
. Consider what happens in the two possible cases:
Option 1:
x is greater than -26:
- x == -25
- x = x - 3 == -28
- -28 > -29, so the position is increased by 3: x = x + 3 == -25
- x == -25
- x = x - 3 == -28
- -28 > -29, so the position is increased by 3: x = x + 3 == -25
- x == -25
- x = x - 3 == -28
- -28 > -29, so the position is increased by 3: x = x + 3 == -25
- ...
Option 2:
x is less than or equal to -26:
- x == -26
- x = x - 3 == -29
- -29 ≤ -29, so the position is kept;
- x == -29
- x = x - 3 == -32
- -32 ≤ -29, so the position is kept;
- x == -32
- x = x - 3 = -35
- -35 ≤ -29, so the position is kept;
- ...
You need to work out what you are actually trying to do, and then fix your logic to match.