Suppose that a, m, and n are positive integers and that m is a factor of n. Explain why a % m = (a % n) % m.

849 Views Asked by At

I'm having some trouble working through this problem.

So far I've managed to deduce the following

If m is a factor of n, then k * m = n, where k is an integer

I can also rewrite the statement as

(a % n) $≡$ (a % m) mod m

So we know that (a % n) - (a % m) is a multiple of m

Where do I go from here to show that a % m = (a % n) % m?

Note that % is just a symbol for mod

3

There are 3 best solutions below

0
On

Let $y_n$ be the integer in $\{0,1,\ldots, n-1\}$ such that $a = q_nn+y_n$ for some integer $q_n$; there is exactly one such $y_n$. Then by definition $y_n = a$ mod $n$.

Let $y_m$ be the integer in $\{0,1,\ldots, m-1\}$ such that $a = q_mm+y_m$ for some integer $q_m$; there is exactly one such $y_m$. Then by definition $y_m = a$ mod $m$.

Then note that $a = q_nn+y_n = q_mm+y_m$, and as $m$ divides $n$, it follows that $a$ can also be written $a = (n/m)q_n m + y_n$ $=q'_n m + y_n$ for $q'_n = (n/m)q_n$; note that $q'_n$ is an integer as both $q_n$ and $n/m$ are integers. So as $a = q'_nm+y_n = q_mm+ y_m$; $q'_n,q_m$ integers, it follows that $(q'_n-q_m)m + (y_m-y_n)$ must be 0, and so $y_n-y_m$ must be a multiple of $m$.

Thus, $y_n-y_m = p_n m$ for some integer $p_n$ [in fact $p_n = q_m-q'_n$], which implies that $y_n$ can be written $y_n = p_n m + y_m$, where $p_n$ is an integer and, as noted earlier, $y_m \in \{0,1,\ldots, m-1\}$. So by definition, (1) $y_m = y_n$ mod $m$.

However, as noted earlier that (2) $y_m = a$ mod $m$ and (3) $y_n = a$ mod $n$, so plugging these into (1) gives $a$ mod $m$ = $(a$ mod $n$) mod $m$.

0
On

Simple, $n=km$. Therefore, $nz+b=a=(km)z+b=m(kz)+b$ so $a \equiv b \pmod {m}$.

0
On

The value of $a\%n$ is unchanged if you alter $a$ by adding or subtracting any multiple of $n$, and similarly for $a\%m$ and any multiple of $m$. However, since $m$ is a factor of $n$, any multiple of $n$ is also a multiple of $m$. That's the key idea.

To see the details, suppose $a\%n=b$, because $a=kn+b$. Suppose further than $n=jm$. Then:

$$\begin{align} (a\%n)\%m &= b\%m\\ &=(b+(kj)m)\%m\\ &=(b+kn)\%m\\ &=a\%m \end{align}$$