Use a modulus operator is something which all programmers must to know. I know it =).
In java we have :
int a = 100 , b = 50, c;
If we do :
c = a % b; // c = 0 because : 100 = 50*2 + 0 | D = d*q + r using simple maths
However I felt a little frustrated for not finding the Why of this operation :
c = b % a; // c = 50 ???? It seems not to have logic when a use D = d*q + r
Can someone could explain me why 50 % 100 is 50 ??? I can't understand very well.
Thanks