x %% y returns the quantity remaining after dividing x by y and using only the integer part of the answer.
7 %% 5 = 2
because 5 goes into 7 one time and then the remaining quantity is two. That is 7 - (5 * 1) = 2. You cannot use 5*2 in that equation because (5 * 2) > 7.
5 %% 7 = 5
because 7 goes into 5 zero times and the remaining quantity is 5. That is 5 - (7 * 0) = 5
18 %% 5 = 3 because 18 - (5 * 3) = 3.