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 yourself. :)


Because the remainder of 3 / 4 = 3.

http://en.wikipedia.org/wiki/Modulo_operator


3 mod 4 is the remainder when 3 is divided by 4.

In this case, 4 goes into 3 zero times with a remainder of 3.

Tags:

C#

Modulus