# rsa / Modular Arithmetic: 4 Important Truths - Number Theory

Part of my series explaining the RSA Algorithm

Modular arithmetic is an important area of Number Theory. Here we’ll cover 4 important but slightly contrived laws of modular arithmetic, useful to understand when tackling other mathematical ideas which use modular arithmetic proofs, as we see in our exploration of Carmichael’s Function.

Notes:

Rule 1

Proof

Remember Bézout’s Identity, which we covered while discussing the Euclidean Algorithm? It states that for any 2 coprimes , a & b there must be values x & y that satisfy:

ax + by = 1

Therefore:

> multiply by `c`
acx + bcy = c

> acx divides by a
a|acx

> and because we stated that
a|bc

> so bcy must divide by a
a|bcy

> therefore divide both sides of the statement by `a`
acx/a + bcy/a = c/a

So their sum, c/a, must also be an integer. Otherwise put, a|c. This is a logical extension of Euclid’s Lemma.

Rule 2

Proof

> IF
ax ≡ ay (mod n)

> THEN
(ax — ay) % n = 0

> Factor out `a`
a(x-y) % n = 0

> Put differently
n|a(x-y)

> Remember that `a` & `n` are coprime
> So applying Rule 1 from above
n|(x-y)

> Meaning that
x ≡ y (mod n)

This rule is known as the rule of cancellation in modular arithmetic.

Rule 3

Proof

There are a finite number of coprimes of n, less than n. Let’s assign this value to the letter t. So there are t coprimes of n which are less than n.

Given the list of numbers:

a¹, a², ..., aᵗ, aᵗ⁺¹ (each mod n)

We know a few things about the list.

If there are only t coprimes to n less than n, and we have t + 1 coprimes less than n in this list, then we know at least two of the numbers in this list will clash – they will result in the same value. The list is not unique.

So we know there are two integers h & j, h < j, such that:

aʰ ≡ aʲ (mod n)

If k = j - h then:

> substitute out j
aʰ ≡ aʰ⁺ᵏ (mod n)

> separating exponents
aʰ ≡ aʰaᵏ (mod n)

We know already know that aʰ is a coprime of n. We can apply Rule #2 from above.

aʰ ≡ aʰaᵏ (mod n)

> cancel aʰ
1 ≡ aᵏ (mod n)

…proving that there must be some positive integer, k for any coprime of n, a such that aᵏ % n = 0.

Rule 4

Proof

Because r is a multiple of k there is some integer s where r/k = s.

aʳ = aᵏˢ = (aᵏ)ˢ

> We know that
aᵏ ≡ 1 (mod n)

> So
aʳ ≡ (aᵏ)ˢ ≡ (1)ˢ ≡ 1 (mod n)

In Summary

We’ve just shown the following:

  1. If a & b are coprime, AND a|bc, THEN a|c

  2. If a & b are coprime, AND ax ≡ ay (mod n), THEN x ≡ y (mod n)

  3. If a & b are coprime, THEN there is a positive integer, k such that aᵏ≡ 1 (mod n)

  4. If aᵏ ≡ 1 (mod n) AND r is a multiple of k THEN aʳ≡ 1 (mod n)

The first rule is not specific to modular arithmetic, although its use in proving the other rules makes it helpful to derive. These truths arise frequently when tackling proofs in number theory. They are a strong foundation for approaching any modular arithmetic problem.

You can see them applied to such a problem when we take a look at Carmichael’s Function.

what else

HRV & Me: Taming a messy stressy mind - [Mar 8, 2026]

Resonance - [Feb 8, 2026]

Where Angels Fear to Tread -- EM Forster - [Jul 13, 2025]

Steve Jobs -- Walter Isaacson - [Jul 10, 2025]

The Fifth Risk -- Michael Lewis - [Jul 10, 2025]

The Ride of a Lifetime -- Bob Iger - [Jul 10, 2025]

James -- Percival Everett - [Jul 3, 2025]

Great Expectations -- Charles Dickens - [Jul 1, 2025]

Hillbilly Elegy -- JD Vance - [Jun 23, 2025]

Principles - [Jun 10, 2025]

Revenge of the Tipping Point -- Malcolm Gladwell - [Jun 9, 2025]

The Grand Babylon Hotel -- Arnold Bennett - [Jun 6, 2025]

The Seven Husbands of Evelyn Hugo -- Taylor Jenkins Reid - [Jun 4, 2025]

Rebecca -- Daphne du Maurier - [Jun 3, 2025]

A Promised Land - Barack Obama - [May 29, 2025]

Less - Andrew Sean Greer - [May 29, 2025]

Careless People - Sarah Wynn-Williams - [May 13, 2025]

Looking Glass War - John Le Carre - [May 7, 2025]

A Murder of Quality - John Le Carre - [May 4, 2025]

London Marathon 2025: Training Retrospective - [May 1, 2025]

The Human Factor - Graham Greene - [Apr 29, 2025]

London Marathon 2025: Race Review - [Apr 28, 2025]

Photos: London Marathon 2025 - [Apr 27, 2025]

Spectating the London Marathon 2025 [Sunday 27th April] - [Apr 27, 2025]

London Marathon 2025: Week 16 - [Apr 26, 2025]

Call for the Dead - John Le Carre - [Apr 23, 2025]

London Marathon 2025: Week 15 - [Apr 21, 2025]

The Manchurian Candidate - Richard Condon - [Apr 16, 2025]

London Marathon 2025: Week 14 - [Apr 13, 2025]

London Marathon 2025: Week 13 - [Apr 5, 2025]

London Marathon 2025: Week 12 - [Mar 30, 2025]

Effortless - Greg Mckeown - [Mar 26, 2025]

Leading - [Mar 26, 2025]

London Marathon 2025: Week 11 - [Mar 23, 2025]

London Marathon 2025: Week 10 - [Mar 16, 2025]

London Marathon 2025: Week 9 - [Mar 9, 2025]

London Marathon 2025: Week 8 - [Mar 2, 2025]

London Marathon 2025: Week 7 - [Feb 22, 2025]

London Marathon 2025: Week 6 - [Feb 16, 2025]

Problems & [Meta] Problem Solving - [Feb 16, 2025]

Little Dribbling - Bill Bryson - [Feb 14, 2025]

Bring Up the Bodies - Hilary Mantel - [Feb 10, 2025]

London Marathon 2025: Week 5 - [Feb 9, 2025]

Three Zero - [Feb 9, 2025]

The iPad mini has genuinely changed my life [no hyperbole] - [Feb 3, 2025]

London Marathon 2025: Week 4 - [Feb 2, 2025]

Coming AI: Valuing Humans in a world where they have no economic value - [Jan 28, 2025]

Value & Price - [Jan 28, 2025]

The Vegetarian - Han Kang - [Jan 27, 2025]

Wolf Hall - Hilary Mantel - [Jan 27, 2025]

London Marathon 2025: Week 3 - [Jan 26, 2025]

Deriving my own proof for Unitary matrices - [Jan 19, 2025]

London Marathon 2025: Week 2 - [Jan 19, 2025]

David Copperfield - Charles Dickens - [Jan 17, 2025]

London Marathon 2025: Week 1 - [Jan 12, 2025]

NYC & DC '24 - [Jan 9, 2025]

Linear Algebra Playground - [Jan 8, 2025]

Configuring an IKEA wireless light switch: Saving you the pain - [Jan 7, 2025]

Goals & Goal-setting - [Jan 7, 2025]

Organisation - [Jan 7, 2025]

Digital Feeds - [Jan 6, 2025]

London Marathon 2025: Training Begins - [Jan 5, 2025]

Everything I've read in 2025 (so far) - [Jan 1, 2025]