Maths in Real Life

Modular Inverses: How to 'Divide' in Clock Arithmetic

EuclidCurve Smart Team · 2026-11-19 · 7 min read

For young mathematicians in the UK, USA, UAE, Singapore and Hong Kong

On a 12-hour clock, 5 hours after 9 o'clock is 2 o'clock. Now a puzzle: in arithmetic mod 11, which number undoes 'multiply by 3'? In ordinary arithmetic the answer is 'divide by 3'. Mod 11 there is no division button, so we need a substitute. Make your guess first.

Guess first: In arithmetic mod 11, which number undoes 'multiply by 3'?

  • 3
  • 4
  • 1/3

It is 4, because 3 × 4 = 12 \equiv 1 \pmod11. Multiplying by 3 and then by 4 is the same as multiplying by 1, so 4 undoes 3.

What is a modular inverse?

The inverse of a modulo m is a whole number x with a x \equiv 1 \pmodm. We write it a^-1. It plays the role of (1)/(a): multiplying by a and then by x brings you back to where you started.

When does an inverse exist?

An inverse of a mod m exists exactly when \gcd(a, m) = 1. Why? If d = \gcd(a, m) > 1, then ax - my is always a multiple of d, so it can never equal 1.

Example: 6 has no inverse mod 9, because \gcd(6, 9) = 3. The multiples of 6 mod 9 are 6, 3, 0, 6, 3, 0 and so on. None of them is 1.

[Interactive tool: open this page in a browser to try it.]

Use the finder above. Set the modulus, then look at the list. Which numbers have partners? Look closely when the modulus is a prime.

Finding it with Euclid's algorithm

Find the inverse of 5 mod 26. Run Euclid: 26 = 5 × 5 + 1. Rearrange: 1 = 26 - 5 × 5. Reducing mod 26, -5 × 5 \equiv 1 \pmod26, so the inverse of 5 is -5 \equiv 21. Check: 5 × 21 = 105 = 4 × 26 + 1.

Your turn

Find the inverse of 2 mod 9 (a number from 1 to 8).

Solution: 2 × 5 = 10 = 9 + 1, so the inverse is 5.

Solving equations mod m

Now solve 3x \equiv 5 \pmod11. Multiply both sides by the inverse of 3, which is 4: x \equiv 4 × 5 = 20 \equiv 9 \pmod11. Check: 3 × 9 = 27 = 2 × 11 + 5.

Guess first: Solve 2x \equiv 1 \pmod7. What is x?

  • x = 2
  • x = 4
  • x = 6

2 × 4 = 8 \equiv 1 \pmod7, so x = 4.

Real life: where inverses are used

Computers work mod a number all the time, and inverses are how they 'divide' safely. RSA codes, which protect online payments, need a private key that is the inverse of a public number mod a big number. Euclid's algorithm finds it (see the Bézout post). Book numbers (ISBN-10) also use arithmetic mod 11 to build a check digit, which helps catch typing mistakes.

Guess first: Does 6 have an inverse mod 9?

  • Yes, it is 3
  • No, because gcd(6, 9) = 3
  • Yes, it is 6

No. The gcd is 3, so no multiple of 6 can leave remainder 1 when divided by 9.

Fermat's shortcut for prime moduli

When m = p is prime, every a from 1 to p - 1 has an inverse, and Fermat’s little theorem gives it directly: a^-1 \equiv a^p-2 \pmodp. Mod 11: 3^5 = 243 = 22 × 11 + 1, so 3^9 = 3^5 × 3^4 \equiv 3^4 = 81 \equiv 4 \pmod11. The inverse of 3 is 4.

Your turn

Using a^-1 \equiv a^p-2 \pmod p, find the inverse of 2 mod 7 (a number from 1 to 6).

Solution: 2^5 = 32 = 4 × 7 + 4, so the inverse is 4. Check: 2 × 4 = 8 \equiv 1.

Where this shows up in exams: IB Maths AA

Congruences and modular arithmetic appear in number theory questions in IB Maths AA, usually in Paper 2 style problems. Show each step, because examiners mark the working.

Explore IB Maths AA

Try it at home: inverses mod 13

  1. Pick the prime 13.
  2. For each number from 1 to 12, find the number that multiplies with it to give remainder 1 mod 13.
  3. Pair the numbers up. Which number is its own inverse?
  4. Bonus: explain why 12 is its own inverse mod 13.

Practice: master modular inverses

Guess first: Practice 1: What is the inverse of 4 mod 9?

  • 4
  • 7
  • 5

4 × 7 = 28 = 3 × 9 + 1.

Your turn

Practice 2: Find the inverse of 10 mod 17.

Solution: 10 × 12 = 120 = 7 × 17 + 1.

Guess first: Practice 3: Does 6 have an inverse mod 15?

  • Yes
  • No

\gcd(6, 15) = 3, so no.

Your turn

Practice 4: Solve 5x \equiv 2 \pmod7. Give x from 0 to 6.

Solution: 5 × 3 = 15 \equiv 1, so x \equiv 3 × 2 = 6. Check: 5 × 6 = 30 = 4 × 7 + 2.

Your turn

Practice 5: What is the inverse of 7 mod 11?

Solution: 7 × 8 = 56 = 5 × 11 + 1.

Quick questions

What is a modular inverse?

The number x with ax = 1 (mod m). It is the mod-m version of 1/a.

When does it exist?

Exactly when gcd(a, m) = 1.

How do I find it?

Run Euclid's algorithm on a and m, then rewrite the last remainder 1 as a combination of a and m. The coefficient of a, reduced mod m, is the inverse.

Why not just divide?

Mod m you cannot always divide, so you multiply by the inverse instead, when it exists.

Written by the EuclidCurve Smart Team. We are the maths and physics tutors behind EuclidCurve. We teach IB, AMC, ESAT and TMUA students in the UK, USA, UAE, Singapore and Hong Kong, and we write about the maths hiding in everyday life.

Keep exploring

Book a free class · Try today's IMO problem