[Solved] Variable isn’t storing correctly? [closed]


Your calculation is effectively canceling:

3 + 3 * -1 = -6

-6 + 3 * -1 = 3

You can do it easier by using a simple if/else:

for (i = 0; i < 2500; i++) {
    if (i % 2 == 0) {
        System.out.println(3 * i);
    } else {
        System.out.println(-3 * i);
    }
}

solved Variable isn’t storing correctly? [closed]