Advanced Mathematics

Modular Arithmetic and Primes

Arithmetic with remainders ("clock arithmetic"), and the primes: unique factorisation, greatest common divisors and Fermat's little theorem.

Needs a step first: 1

Two integers are congruent modulo nn, written a≡b(modn)a \equiv b \pmod n, if they leave the same remainder on division by nn; you can add and multiply while keeping only remainders. Every integer above 1 factors into primes in exactly one way, Euclid's algorithm finds greatest common divisors fast, and Fermat's little theorem says ap−1≡1(modp)a^{p-1} \equiv 1 \pmod p when the prime pp does not divide aa. These facts power public-key cryptography (RSA) and the period-finding in Shor's algorithm, and give the first examples of groups.

Where it shows up: RSA encryption is modular powers, hash functions and checksums use remainders, and Shor's quantum algorithm factors numbers by finding the period of ax mod Na^x \bmod N.

How to hold it: In your head

See arithmetic modulo nn as arithmetic on a clock, and explain why Euclid's algorithm finds a gcd and why Fermat's little theorem cuts a huge power down to size; leave big moduli to the computer.

What knowing it looks like

  • Find the remainder of a large power such as 2502^{50} modulo 7 without a calculator.
  • Run Euclid's algorithm to find gcd⁡(252,198)\gcd(252, 198) and use it backwards to solve 7x≡1(mod26)7x \equiv 1 \pmod{26}.
  • Explain why there are infinitely many primes.

Test yourself

Find the remainder when 31003^{100} is divided by 77.
Show the worked answer
The powers of 3 modulo 7 are 3,2,6,4,5,13, 2, 6, 4, 5, 1, so 36≡1(mod7)3^6 \equiv 1 \pmod 7 (as Fermat's little theorem predicts). Since 100=6×16+4100 = 6 \times 16 + 4, 3100=(36)16⋅34≡34=81≡4(mod7)3^{100} = (3^6)^{16} \cdot 3^4 \equiv 3^4 = 81 \equiv 4 \pmod 7. The remainder is 44.

Needs a step first: 1

Learn it with an AI

Copy this prompt into any AI assistant. It will take you through step by step at your level and finish with the test above.

Be my maths tutor. I'm learning "Modular Arithmetic and Primes" (Core tier): Arithmetic with remainders ("clock arithmetic"), and the primes: unique factorisation, greatest common divisors and Fermat's little theorem.
I already know: Logic and Proof.
Teach it Socratically: first ask what I already know; then explain the core idea with one concrete example and why it's true; then give me three problems, one at a time, easy to hard. Wait for my answer, check every step, and point out mistakes without giving the answer away.
Finish by testing me with this: Find the remainder when $3^{100}$ is divided by $7$.
Use LaTeX for formulas. When you say where it's used later (machine learning, quantum mechanics), be specific.

On the way to

Recommended