How does the modulus operator work?

in C++ expression a % b returns remainder of division of a by b (if they are positive. For negative numbers sign of result is implementation defined). For example: 5 % 2 = 1 13 % 5 = 3 With this knowledge we can try to understand your code. Condition count % 6 == 5 … Read more

C# modulus operator

I wasn’t quite sure what to expect, but I couldn’t figure out how the remainder was 3. So you have 3 cookies, and you want to divide them equally between 4 people. Because there are more people than cookies, nobody gets a cookie (quotient = 0) and you’ve got a remainder of 3 cookies for … Read more