New course! Every coder should learn Generative AI!
Try a free lesson+ 3
There are 2 reasons...
- Modulus (%) has same precedence as multiplication and division, even if it had same precedence as addition it would be calculated left to right
- The possible reminders of division by 2 are 0 or 1...
1 + 10 = 11
0 + 10 = 10