1

It is easy to calculate small examples like $26\pmod {5}$ but how do you calculate examples like $9801 \pmod {32}$ without a calculator.

Bill Dubuque
  • 272,048
  • 2
    Long division ? – lulu Dec 07 '16 at 19:12
  • 1
    Subtract $3200$ until what you have is less than $3200$. Then subtract $320$ until what you have is less than $320$. Then do it for $32$. You can also use other multiples if you want. For instance, I know that $9600$ is divisible by $32$, so that takes me directly to $201$. Then I know that $96$ is divisible by $32$, which means $192$ is divisible by $32$, and that leaves me with $9$. – Arthur Dec 07 '16 at 19:12
  • 1
    @MithleshUpadhyay That's specifically for big powers. – Arthur Dec 07 '16 at 19:13
  • @Arthur, your first comment on this post is nice answer. That should be as answer. – Mithlesh Upadhyay Dec 07 '16 at 19:17
  • I'm sticking with "long division". Here we (trivially) get $\frac {9801}{32}=306.28125$. We deduce that $9801=306\times 32+9$ so the answer is $9$. – lulu Dec 07 '16 at 19:17
  • You can convert to binary, look at the last 5 digits and convert back. More generally, you work with the prime factors. – Doug M Dec 07 '16 at 19:19
  • @lulu Generally we can compute the remainder much faster than long division using the method described in the second half of my answer, e.g. see the simple calculation there for $,10210\bmod 32,$ whihc can be done mentally in under $10$ seconds. – Bill Dubuque Dec 07 '16 at 20:25
  • You might recognize $9801 = 99^2$, so $9801 \bmod 32 = 99^2 \bmod 32 = (99 \bmod 32)^2 \bmod 32 = 3^2 \bmod 32 = 9$. – Brian Tung Dec 07 '16 at 20:31
  • @Brian In this case that's not any faster than casting $32$'s, which computes it as $,4(2)+1,$ vs. $3^2.,$ But casting works much more generally, e.g. see my answer. – Bill Dubuque Dec 07 '16 at 21:08
  • @BillDubuque: I make no claims about faster. Just a different way. – Brian Tung Dec 07 '16 at 21:26

1 Answers1

2

Note $\ {\rm mod}\ 32\!:\,\ \color{#0a0}{100}\equiv\color{#c00}4\ \ \Rightarrow\ \ \begin{align} 9801&\equiv (\color{#0a0}{100}\!-\!2)\cdot \color{#0a0}{100} + 1\\ &\equiv \ \ \ \ (\color{#c00}{4}\!-\!2)\ \cdot\ \color{#c00}4\ +\ 1\\ &\equiv\ \ \ \ 9\end{align}$

If we write an integer in radix $100$ as a polynomial $\ n = P(100) = \sum d_i 100^i $ then

$\qquad {\rm mod}\ 32\!:\,\ \color{#0a0}{100}\equiv\color{#c00}4\,\Rightarrow\, n = P(\color{#0a0}{100})\equiv P(\color{#c00}4)\ $ by the Polynomial Congruence Rule.

In older language this would be called casting-out $32$'s in radix $100$.

For larger numbers it is easier to evaluate $\,P(4)\,$ by the method described here, i.e. continually replace the two most significant radix $100$ digits $\,c,d\,$ by the digit $\, 4c\!+\!d\bmod{32},\,$ so above we replace $\,c,d = 98,01\,$ by $\, 4(98)+01\equiv 4(2)+1\equiv 9\pmod{32}$

Another example $\!\! \underbrace{01,02}_{\large 4(1)+2\,\equiv\,\color{#c00} 6\ \ \ \ \ }\!\!\!\!\!\!\!,10\, \equiv\!\!\!\!\! \underbrace{\color{#c00}6,10}_{\large 4(6)+10\,\equiv\, \color{#0a0}2}\!\!\!\!\!\!\equiv\color{#0a0}2\,\pmod{32} $

Indeed, $ $ dividing: $\ \ 10210\, =\, 319\cdot 32 + \color{#0a0}2$

Bill Dubuque
  • 272,048