a mod b, when b is greater than a

1.8k Views Asked by At

Why

6 % 10 = 6

As fa as I know 10 % 6 = 4, but I don't know how to handle the first one

Thanks!

2

There are 2 best solutions below

2
On

The modulo operator a mod b gives the remainder when you divide a by b. Can you then work out the remainder when 6 is divided by 10?

0
On

Division Theorem:

For any integer $M$ and any natural $n$ then if you divide $N$ by $n$ you will get a unique integer quotient $q$ and unique remainder integer $r$, between $0$ (inclusive) but less than $n$ so that $M= qn + r$.

$r$ is the remainder and $0 \le r < n$ and $q$ is the quotient and $q \le \frac Mn < q+1$.

And $M\% n = r$. That is the definition.

SO if $M = 6$ and $n = 10$ what are $q$ and $r$ so that that:

$6 = q*10 +r$ and $q \le \frac{6}{1} < q+1$?

THe answers are:

$q=0$ and $r =6$.

$6 = 0*10 + 6$.

And so $6\% 10 =6$