Congruences
means : and leave the same remainder on division by . Congruences can be added, subtracted and multiplied like equations: if and then and . So you may reduce at every step of a computation — which is what makes easy.
Reducing mod is forgetting everything about a number except its remainder, and the miracle is that arithmetic still works on remainders alone: if and , then , so the products differ by a multiple of too. Picture the residues around a clock; adding moves around it, and whole laps do not matter. The one operation that needs care is division, taken up in the third section.
Today is Tuesday. What day is it days from now? Days repeat every , so only matters: . Fourteen whole weeks bring us back to Tuesday, and more days reach Thursday.
Find . Look for a small power that is : . Then write the exponent in multiples of : . Multiplying congruences is what licenses replacing by inside the power. Answer .
Find the remainder of on division by . Squares first: and . So and , and the sum is . The remainder is — no need to know that has digits.
Reducing an EXPONENT mod . It is tempting to say because ; but . Bases may be reduced mod ; exponents may only be reduced mod the length of the cycle of powers (here , since ), and gives the correct .
Find the last digit of .
Show the answerHide the answer
The last digit is the value mod . Powers of mod run and then repeat, since . As , : the last digit is .
Proofs by Residue Classes
To prove a statement about all integers whose truth depends only on , check the residues . Every integer is congruent to exactly one of them, so checks cover infinitely many cases. Standard facts proved this way: squares are or ; squares are ; squares are or .
Why is checking finitely many cases enough? Because if then , , and so on for any polynomial with integer coefficients: the value mod is decided by the residue class. So the infinite set of integers collapses into representatives, and a finite table becomes a proof. Choose to match the claim — divisibility by suggests checking mod and mod .
Show that is never divisible by . Square each residue: , , , , . So mod and — never . Notice that and land together, as do and : and always have the same square.
Since with , it suffices to show and . Mod : and . Mod : , , . Every class gives , so both primes divide , and so does . (Factored, is a product of three consecutive integers.)
If in integers, show that divides or . Squares mod are (for ) or (for ). If neither nor were a multiple of , then , but can only be or . So one of is a multiple of — as in and .
Checking a few values of instead of every residue class. is prime for — forty successes in a row — yet at it equals . Examples suggest; only a complete case check (or an algebraic argument) proves.
Prove that is never divisible by .
Show the answerHide the answer
Check the three classes mod : give , so . None is , so for every integer .
Inverses and Linear Congruences
has an inverse mod (a number with ) exactly when ; find it from Bézout. The congruence has a solution iff , and then exactly solutions mod .
Solving is solving in integers, and by Bézout that is possible exactly when divides . When , multiplying by undoes multiplication by , just as division does for ordinary equations. When , multiplication by is many-to-one: it squeezes the residues onto only the multiples of , each hit times — which is where the solutions come from.
If and , then . If , you can only conclude .
, so has an inverse and there is exactly one solution. Find the inverse by trying multiples of until one is more than a multiple of : , so . Multiply both sides by : . Check: . ✓
divides , so there are solutions. Divide everything, modulus included, by : . Now (as ), so . Back mod that is or . The figure shows why: only ever lands on even residues, each one twice.
and : three solutions. Divide by : . Since , and . Mod the solutions are . Check : . ✓ By contrast has NO solution: does not divide (an even number cannot be more than a multiple of ).
Dividing both sides of a congruence by a number that shares a factor with the modulus. does NOT give ; also works (). Dividing by is allowed only if the modulus is divided too: .
Find the inverse of modulo .
Show the answerHide the answer
; ; . Back: . So . Check: . ✓
Why It Works
If then for some , so any common divisor of and divides : . Conversely, if , Bézout gives , and reducing mod leaves . The residues coprime to therefore form a group under multiplication — closed, with identity , every element invertible — and the size of that group is Euler's , which is where the Fermat–Euler topic begins.