[modulo] Why does 2 mod 4 = 2?

Someone contacted me and asked me to explain in more details my answer in the comment of the question. So here is what I replied to that person in case it can help anyone else:

The modulo operation gives you the remainder of the euclidian disivion (which only works with integer, not real numbers). If you have A such that A = B * C + D (with D < B), then the quotient of the euclidian division of A by B is C, and the remainder is D. If you divide 2 by 4, the quotient is 0 and the remainder is 2.

Suppose you have A objects (that you can't cut). And you want to distribute the same amount of those objects to B people. As long as you have more than B objects, you give each of them 1, and repeat. When you have less than B objects left you stop and keep the remaining objects. The number of time you have repeated the operation, let's call that number C, is the quotient. The number of objects you keep at the end, let's call it D, is the remainder.

If you have 2 objects and 4 people. You already have less than 4 objects. So each person get 0 objects, and you keep 2.

That's why 2 modulo 4 is 2.