Working Modulo n
means . You may add, subtract, and multiply congruences.
In plain terms. Only the remainder matters, so replace big numbers by their remainders and do easy arithmetic.
Example. : since , .
Why it works. If and , then and differ by a multiple of , and so do and . So the remainder of a sum or product depends only on the remainders of the pieces. Powers are repeated products, which is why a power's remainder cycles: there are only possible remainders, so the sequence must eventually repeat, and from then on it repeats forever.
If is prime and , then .
In plain terms. Raising to the power resets you to modulo a prime, so huge exponents shrink fast.
Example. : , and , so .
What is the last digit of ?
Spotting it. "Last digit" means "remainder mod ", and powers of a fixed number cycle mod . Find the cycle, then reduce the exponent modulo its length.
Step 1. , , , . The cycle has length .
Step 2. , so . The last digit is .
What is the remainder when is divided by ?
Spotting it. From some point on, every term is a multiple of and contributes nothing. Find that point.
Step 1. is divisible by , and every later factorial is a multiple of .
Step 2. Only matters, so the remainder is .
For how many integers with is divisible by ?
Spotting it. Whether divides depends only on , so check the five residues once and then count.
Step 1. give . So or .
Step 2. Each block of five consecutive integers contains exactly two such , and to is twenty blocks: values.
Reducing the exponent modulo the wrong number. The exponent must be reduced modulo the CYCLE LENGTH, not the modulus. For : reducing mod gives , which is wrong. The powers of mod run with period , and , so .
What is the remainder when is divided by ?
Show the answerHide the answer
By Fermat, , and , so . Now , so . The remainder is .
Chinese Remainder and Last-Two-Digit Problems
If , the pair , has exactly one solution modulo .
Solve by substitution: from write , substitute into to get , so and . Checking both congruences at the end costs seconds and catches the common slip of inverting the wrong coefficient.
for a prime ; more generally when , with .
Last two digits means modulo : , and squaring up gives , so the last two digits are . The trap is applying Euler when — for the cycle still exists but starts later, so compute modulo and modulo and recombine.
What is the smallest positive integer leaving remainder when divided by and remainder when divided by ?
Step 1 — .
Step 2 — , so .
Step 3 — (since ), so and the smallest is , . Check: and ✓
What are the last two digits of ?
Spotting it. Last two digits means mod . Euler would reduce the exponent mod , but squaring a couple of times shows cycles much faster: , and .
Step 1. .
Step 2. , so . The last two digits are .
What are the last two digits of ?
Spotting it. , so Euler's theorem does not apply mod . Split into coprime parts, work in each, and recombine with CRT.
Step 1. Mod : .
Step 2. Mod : and , so .
Step 3. Find with : among only is a multiple of . The last two digits are .
Using Euler when the base and modulus share a factor. ", so " is false: is even, so it cannot be more than a multiple of (in fact ). Anyone who then writes is wrong; . Split the modulus instead.
What is ?
Show the answerHide the answer
and , so . Since , .
Squares, Remainders and Impossibility
Every square is or , and , or ; mod it is or . To prove that an equation has NO integer solutions, find a modulus in which the two sides can never agree.
Why it works. Only the remainder of matters, so check each residue once: , and because one of is even. An equation that holds for integers must hold mod every , so a single modulus where it fails rules out every integer solution at once. A modulus can prove impossibility; it can never prove that a solution exists.
Can be written as the sum of two perfect squares?
Spotting it. A sum of two squares is a sum of two numbers from mod , so it is , or .
Step 1. .
Step 2. No: is not a possible remainder.
How many of the integers can be written as with and nonnegative integers?
Spotting it. , and the two factors and have the same parity (they differ by ). That decides which are possible.
Step 1. If is odd, . If , .
Step 2. If : two factors of the same parity multiply to an odd number or to a multiple of , never to . So these fail.
Step 3. The failures are , which is numbers, so can be written.
Exactly one of , , , cannot be written as a sum of three perfect squares. Which one?
Spotting it. Mod is too coarse for three squares (three terms from reach every residue). Mod squares are , and three of them can make every residue EXCEPT : sums of three values from give and then .
Step 1. , so is impossible.
Step 2. The others do work, for instance , and . (The mod- test alone could not have shown that; examples do.)
Treating a passed test as a proof. passes the mod- test for a sum of two squares, yet is NOT a sum of two squares: the squares below it are , and no two of them add to . A modulus can only rule things out. To show something IS possible, exhibit it.
Show that has no solutions in integers.
Show the answerHide the answer
Work mod : the equation becomes . But squares are or (, , ). So there is no solution.