# question on %% in an equation

Hi there, I have trouble to understand the use of %%. can someone explain the process of the calculation? Thanks in advance.
x<-5
y<-7
x %% y
[1] 5
y %% x
[1] 2

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.

Thanks for answering me, very appreciated!

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.