It's a problem for my computer science course. The answer given is 4, but how do you get that answer? I don't understand what the % means in this case.
-
% mean "modulus" (usually abbreviated to "mod")
mod means divide to get the integer answer with remainder, and use the remainder, i.e.,
17 / 2 = 8 R1, so 17 % 2 = 1
mod means divide to get the integer answer with remainder, and use the remainder, i.e.,
17 / 2 = 8 R1, so 17 % 2 = 1
-
17 % 2 means 17 mod 2 which is equal to 1;
4 + 17 % 2 - 1
= 4 + 1 - 1
= 4
4 + 17 % 2 - 1
= 4 + 1 - 1
= 4