Question with operators

Very easy question (I believe) that I do not know the answer

Why this "n = n*3 +1" is not equal to this "n *= 3 +1"?

If n= 3

First method: 3*3 + 1 = 10
Second method: 3*(3+1) = 12

So how can I use the second method "n *= 3 +1" and get the same input that method one?
Last edited on
Basically you can't. But you can make the first equation evaluate the same as the second by using parentheses "n = n * (3 + 1)".

Topic archived. No new replies allowed.