Sub topic 6
Last two digits of sums and products
What this chapter assumes
You should already know that the unit digit of a number is its remainder mod 10, and that the last two digits are its remainder mod 100. You should also be comfortable with unit-digit arithmetic for sums and products, from the earlier chapters. Here we extend those ideas to two digits. Powers of numbers come in the next chapter, and the mod 4 and mod 25 split comes after that.
The core rule
The last two digits of a non-negative integer N are N mod 100. A result such as 7 is written as 07 when you report last two digits.
Remainders mod 100 behave well under addition, subtraction and multiplication:
- (a + b) mod 100 = ((a mod 100) + (b mod 100)) mod 100
- (a − b) mod 100 = ((a mod 100) − (b mod 100)) mod 100
- (a × b) mod 100 = ((a mod 100) × (b mod 100)) mod 100
So only the last two digits of each input matter. A 7-digit factor can be replaced by its last two digits before you multiply, and you can reduce again after every step to keep the numbers small.
Division is not on this list. You cannot divide residues and expect a correct result, so never reduce a quotient by dividing last-two-digit values.
Products: reduce, multiply, reduce
Find the last two digits of 387 × 4521.
- 387 mod 100 = 87 and 4521 mod 100 = 21.
- 87 × 21 = 1827.
- 1827 mod 100 = 27.
The answer is 27. The full product is 1 749 627, which confirms it.
With several factors, reduce after each multiplication. For 43 × 49 × 11:
- 43 × 49 = 2107, which reduces to 07.
- 07 × 11 = 77.
The answer is 77. The intermediate value 07 is just 7, and you carry it forward as 7.
Use negative residues near multiples of 100
Any number close to a multiple of 100 is easier to handle as a small positive or negative residue. A residue of −3 means "3 less than a multiple of 100".
| Number ends in | Treat it as |
|---|---|
| 99 | −1 |
| 98 | −2 |
| 97 | −3 |
| 01 | +1 |
| 02 | +2 |
| 03 | +3 |
Find the last two digits of 1999 × 2001 × 1997 × 2003.
- 1999 ≡ −1, 2001 ≡ 1, 1997 ≡ −3, 2003 ≡ 3 (mod 100).
- The product is (−1)(1)(−3)(3) = 9.
- The last two digits are 09.
Two negative signs cancel, so keep track of how many negatives you have. An odd count makes the product negative, and then you add 100 at the end.
Find the last two digits of 99 × 97 × 93.
- (−1)(−3)(−7) = −21.
- −21 + 100 = 79.
The answer is 79. As a check, 99 × 97 × 93 = 893 079.
Sums: add the last two digits and carry nothing forward
For a sum of many terms, replace each term by its last two digits and add. The tens digit of the total depends on the tens digits of all the terms plus any carry from the units column, and working mod 100 handles that carry automatically.
Find the last two digits of 7 + 77 + 777 + 7777 + 77777.
- The last two digits of the terms are 07, 77, 77, 77, 77.
- Their sum is 7 + 77 + 77 + 77 + 77 = 315.
- 315 mod 100 = 15.
The answer is 15. The exact sum is 86 415.
A factorial sum: terms that vanish
Many CAT questions sum a long series in which later terms are multiples of 100. Those terms contribute 00 and can be ignored. Find the last two digits of 1! + 2! + 3! + … + 100!.
10! = 3 628 800 ends in 00, and every larger factorial contains 10! as a factor, so it is also a multiple of 100. Only 1! through 9! matter.
| n | n! | n! mod 100 |
|---|---|---|
| 1 | 1 | 01 |
| 2 | 2 | 02 |
| 3 | 6 | 06 |
| 4 | 24 | 24 |
| 5 | 120 | 20 |
| 6 | 720 | 20 |
| 7 | 5040 | 40 |
| 8 | 40320 | 20 |
| 9 | 362880 | 80 |
The sum of the last column is 1 + 2 + 6 + 24 + 20 + 20 + 40 + 20 + 80 = 213, so the answer is 13.
Differences: avoid negative remainders
For a − b, reduce both numbers and subtract. If the result is negative, add 100.
Find the last two digits of 4123 − 987.
- 23 − 87 = −64.
- −64 + 100 = 36.
The answer is 36, and the exact difference is 3136.
Shortcuts for endings 25, 75, 50 and 00
Some endings make the product depend on very little information.
- A number ending in 00 times any integer ends in 00.
- A number ending in 25 or 75 behaves like 25 times an odd number. In general, 25k mod 100 = 25 × (k mod 4). So 25 times a multiple of 4 ends in 00, and times k with k mod 4 = 1, 2, 3 ends in 25, 50, 75.
- 50k mod 100 is 00 if k is even and 50 if k is odd.
- Any product containing a factor ending in 25 or 75 and an even factor ends in 00 or 50. It ends in 00 only when the product of the other factors is a multiple of 4.
Example: find the last two digits of 75 × 123 × 457.
- 75 = 25 × 3, so the product is 25 × (3 × 123 × 457).
- Mod 4: 3 × 3 × 1 = 9 ≡ 1.
- So the product ends in 25 × 1 = 25.
The exact product is 4 215 825, which ends in 25.
Two more patterns are worth knowing. Both follow from the rules above.
- 25 × 25 = 625 ends in 25, and 76 × 76 = 5776 ends in 76. Multiplying any number of factors that each end in 25 (or each end in 76) keeps that ending.
- A number ending in 01 times a number ending in 01 ends in 01, since (1 + 100a)(1 + 100b) ≡ 1 mod 100.
Choosing a method
Checking by computer
The following Python code applies the same rules, then compares them with an exact calculation. The format :02d pads a single digit with a leading zero.
from math import factorial, prod
def last_two_product(numbers):
result = 1
for n in numbers:
result = (result * (n % 100)) % 100
return result
def last_two_sum(numbers):
return sum(n % 100 for n in numbers) % 100
def last_two_difference(a, b):
return (a % 100 - b % 100) % 100
print(f"{last_two_product([387, 4521]):02d}") # 27
print(f"{last_two_product([43, 49]):02d}") # 07
print(f"{last_two_product([1999, 2001, 1997, 2003]):02d}") # 09
print(f"{last_two_sum([7, 77, 777, 7777, 77777]):02d}") # 15
print(f"{last_two_difference(4123, 987):02d}") # 36
# 1! + 2! + ... + 100!
total = sum(factorial(n) for n in range(1, 101))
print(f"{total % 100:02d}") # 13
# The shortcut agrees with the full computation
assert last_two_product([75, 123, 457]) == prod([75, 123, 457]) % 100Python's % operator returns a non-negative result for a positive modulus, so last_two_difference does not need the "add 100" step. By hand you do need it.
Common errors
- Dropping the leading zero. If the product is 2107, the last two digits are 07, not 7. This matters when the answer is a two-digit option, or when you carry the result into a later step.
- Using only unit digits. The unit digit of a product comes from the unit digits alone. The tens digit also depends on the tens digits and the carry, so reduce mod 100, not mod 10.
- Forgetting to fix a negative result. A residue of −21 means 79, not 21.
- Dividing residues. The last two digits of (a × b) / c cannot be found from the last two digits of a × b. Cancel common factors first, or work with the full factorisation.
- Cutting a number in the wrong place. In 5 072, the last two digits are 72, so reduce 5 072 to 72, not 50 or 07.
- Missing terms that vanish. In a long series, look for the point after which every term is a multiple of 100, as with n! for n ≥ 10.
Practice
Exercise
Find the last two digits of 1997 × 2003 × 1998 × 2002.
Show answer
Reduce: 1997 ≡ −3, 2003 ≡ 3, 1998 ≡ −2, 2002 ≡ 2 (mod 100). The product is (−3)(3)(−2)(2) = 36. The last two digits are 36.
Exercise
Find the last two digits of 25 × 37 × 1234.
Show answer
25 × k mod 100 equals 25 × (k mod 4). Here k = 37 × 1234, and k mod 4 = (1 × 2) mod 4 = 2. So the result is 25 × 2 = 50. The last two digits are 50 (the exact product is 1 141 450).
Exercise
Find the last two digits of 1! + 2! + 3! + … + 9! + 10! + 11!, and explain why 10! and 11! do not change the answer.
Show answer
10! = 3 628 800 and 11! = 39 916 800 both end in 00, so they add 0 to the last two digits. The sum 1! + … + 9! = 409 113, so the answer is 13.