Question with operators

Oct 9, 2016 at 1:32pm
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 Oct 9, 2016 at 1:38pm
Oct 9, 2016 at 3:13pm
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.