4

As described on Wikipedia: $$\frac{a}{b} \bmod{n} = \left((a \bmod{n})(b^{-1} \bmod n)\right) \bmod n$$

When I apply this formula to the case $(1023/3) \bmod 7$: $$\begin{align*} (1023/3) \bmod 7 &= \left((1023 \bmod 7)((1/3) \bmod 7)\right) \bmod 7 \\ &= ( 1 \cdot (1/3)) \mod 7 \\ &= ( 1/3) \mod 7 \\ &= 1/3 \end{align*} $$ However, the real answer should be $(341) \bmod 7 = \mathbf{5}$.

What am I missing? How do you find $(a/b) \bmod n$ correctly?

Paul Lo
  • 187
  • 1
    The number $b^{-1}\mod n$ is not the same as $1/b$. Rather, it is the modular inverse of $b$ with respect to $n$. The question I linked above describes methods of computing the inverse of a number modulo $n$. – apnorton Jan 28 '15 at 18:24
  • Thank you @anorton , let me read it first. – Paul Lo Jan 28 '15 at 18:35
  • @anorton Why do you think $,b^{-1} \ne 1/b?\ $ What does $,1/b,$ mean to you? – Bill Dubuque Jan 28 '15 at 18:35
  • @BillDubuque He had in mind that $\frac{1}b\mod n\neq \frac{1}b$, which was the problem in OP's attempt. – user26486 Jan 28 '15 at 18:38
  • 1
    @user314 Whether or not it makes sense depends on how much coercion (or notational abuse) one tolerates. The OP should learn about mod as a congruence relation (vs. operation). – Bill Dubuque Jan 28 '15 at 18:50
  • @BillDubuque, the lack of understanding of congruence modulo a number as an equivalence relation seemed to be a big stumbling block for my students when I was teaching Algebra. – Lubin Jan 28 '15 at 19:05
  • @BillDubuque I know that some people use $1/b$ to denote the multiplicative inverse of $b$ (for instance, this is important when discussing formal power series, as $f^{-1}$ is a functional inverse, while $1/f$ is its multiplicative inverse). However, I find it easier to insist on the notation $b^{-1}$ for students new to modular arithmetic; it reinforces the distinction between the general idea of inverses from the specific idea of division. – apnorton Jan 28 '15 at 22:58
  • @anorton But it is important to forget this distinction asap, since use of fractions greatly simplifies modular arithmetic, in the same way that they greatly simplify integer arithmetic. See also here. – Bill Dubuque Jan 28 '15 at 23:05
  • @BillDubuque Fair enough--you've taught modular arithmetic longer than I've known it, so I'll trust your experience. :) – apnorton Jan 28 '15 at 23:09

1 Answers1

2

$\frac{1}{3}\mod 7 = 3^{-1}\mod 7$

You need to solve below for finding $3^{-1}\mod 7$ : $$3x\equiv 1\pmod 7$$

Find an integer $x$ that satisfies the above congruence

user26486
  • 11,331
AgentS
  • 12,195
  • Let me think for a while, thanks for your answer! – Paul Lo Jan 28 '15 at 18:31
  • 1
    take your time :) if it helps, think of it like this : find an integer $x$ that makes $3x-1$ divisible by $7$ – AgentS Jan 28 '15 at 18:32
  • 1
    when x = 5, 12, 19 it will do, so 3^(-1) mod 7 should be 5, the answer is ((1023 mod 7)*(5)) mod 7 = 5 , is my deduction right? – Paul Lo Jan 28 '15 at 18:42
  • Yes, that looks perfect! – AgentS Jan 28 '15 at 18:45
  • I've edited a bit of the notation in your answer because the fractional notation in modular arithmetic should not be confused with the regular fractions we work with in the rational number system. They are different things and this notation is, unfortunately, misleading. – user26486 Jan 28 '15 at 18:49