0

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

  • What is a % n? I have never seen that notation before – Mike Mar 10 '19 at 02:00
  • 1
    @Mike modulo remainder - used in most programming languages – enedil Mar 10 '19 at 02:01
  • 1
    My bad. This question is related to computer science and we usually write mod as % (as that is what it is usually in code.) –  Mar 10 '19 at 02:01
  • 2
    Hint: If $\ x - y\ $ is a multiple of $\ m\ $, then $\ x\equiv y \left(\mathrm{mod}\ m\right)\ $. – lonza leggiera Mar 10 '19 at 02:06
  • 4
    @mike frustratingly, it differs from the meaning of mod used in purer math. In the quotient remainder theorem, we know that given integers $a$ and $n$ there exist unique integers $q$ and $r$ such that $0\leq r< n$ such that $a=qn+r$. The result of a%n is precisely that $r$ in the case of them all being non-negative integers. If any are negative... sadly it is programming language dependent. – JMoravitz Mar 10 '19 at 02:08
  • As for how I would approach this problem, I would repeatedly invoke the quotient remainder theorem and specifically point out the uniqueness clause of it, which when done correctly will show that the remainder that is the result of (a%n) will when modded by m have the same remainder as if you had done it directly – JMoravitz Mar 10 '19 at 02:14
  • 1
    The left hand side is the remainder of $a$ when divided by $m$. If $m$ divides $n$, say $n=mk$, then $a%n$ is the remainder of $a$ when divided by $n$, say $s$, so that $a=nq+s = m(kq) +s$. Now verify that the remainder of dividing $s$ by $m$ is the same as the remainder of dividing $a=m(kq)+s$ by $m$. – Arturo Magidin Mar 10 '19 at 02:17

3 Answers3

2

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

Robert Shore
  • 23,332
1

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$.

John Omielan
  • 47,976
Mike
  • 20,434
0

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}$$

G Tony Jacobs
  • 31,218