Short-cut for computing some large number N (mod 3)

56 Views Asked by At

Is it OK to assert that a number (mod 3) is the sum of each of its digit (mod 3), i.e., for an n-digit number represented by a1a2a3...an (mod 3) = a1 (mod 3) + a2 (mod 3) + a3 (mod 3) + ... + an( mod 3) ?

1

There are 1 best solutions below

2
On BEST ANSWER

Not quite, but you're close. Assuming you mean the decimal digits, then what you have is that

$$d_nd_{n-1}\dots d_1d_0\equiv (d_n\hspace{-1em}\mod 3+d_{n-1}\hspace{-1em}\mod 3+\dots+d_0\hspace{-1em}\mod 3)\pmod 3$$

The reason that you can't just say that the number mod $3$ "is" the sum of all of its digits (with each digit taken mod $3$) is that that value might be too large; even though they're in the same equivalence class, when we talk about $n\mod 3$ we usually mean the smallest member of that equivalence class; in other words, the remainder when $n$ is divided by $3$. So, for instance, $111111\mod 3$ 'is' $0$, since it's divisible by $3$ - but $1+1+1+1+1+1$ is $6$. But of course $0\equiv 6\pmod 3$, so they are in the same residue class.

The reason that this is so, incidentally, is because $10\equiv 1\pmod 3$, so (because modularity 'respects' multiplication), $10^n\equiv 1\pmod 3$ for all $n$; and since $d_nd_{n-1}\ldots d_1d_0$ is shorthand notation for $d_n\times 10^n+d_{n-1}\times 10^{n-1}+\ldots$, we can write $$\begin{align} d_nd_{n-1}\ldots d_0 &= d_n\times 10^n+d_{n-1}\times 10^{n-1}+\dots\\ &\equiv d_n\hspace{-1em}\mod 3\times 10^n\hspace{-1em}\mod 3+d_{n-1}\hspace{-1em}\mod 3\times 10^{n-1}\hspace{-1em}\mod 3+\dots \\ &\equiv d_n\hspace{-1em}\mod 3\times 1+d_{n-1}\hspace{-1em}\mod 3\times 1+\dots\\ &\equiv (d_n\hspace{-1em}\mod 3+d_{n-1}\hspace{-1em}\mod 3+\dots+d_0\hspace{-1em}\mod 3) \pmod 3 \end{align}$$