Sub topic 13
Remainder Problems: Same and Different Remainders
This chapter assumes you can do division with remainder, compute HCF and LCM from prime factorization, and use Euclid's algorithm. It also assumes you can handle simple algebra such as N = q·d + r. The goal is to read a remainder question and pick the right tool, HCF or LCM, within seconds.
The core idea
If N leaves remainder r when divided by d, then N = q·d + r with 0 ≤ r < d. Two consequences drive every problem here:
N − ris an exact multiple ofd, soddividesN − r.dmust be larger thanr. If a candidate divisor is not larger than the remainder, discard it.
Every problem below is a variation of this: shift the numbers so the remainders disappear, then use HCF or LCM.
Choosing the tool
HCF questions ask for a divisor. LCM questions ask for a number that is divided by several divisors. The remainder pattern then decides the shift.
Finding the divisor (HCF problems)
Same remainder given
Find the largest number that divides 245 and 1029 leaving remainder 5 each time. Both 245 − 5 = 240 and 1029 − 5 = 1024 must be divisible by the divisor. The largest such divisor is HCF(240, 1024) = 16. Since 16 > 5, the answer is valid.
from math import gcd
# Largest number that divides 245 and 1029 leaving remainder 5 in each case
print(gcd(245 - 5, 1029 - 5)) # 16Different remainders given
Find the largest number that divides 398, 436 and 542 leaving remainders 7, 11 and 15. Subtract each remainder from its own number:
- 398 − 7 = 391 = 17 × 23
- 436 − 11 = 425 = 17 × 25
- 542 − 15 = 527 = 17 × 31
The HCF is 17, and 17 > 15, so the answer is 17.
Same remainder, but its value is not given
Find the largest number that leaves the same remainder when it divides 59, 101 and 143. You do not know r, but it cancels in the differences:
- 101 − 59 = 42
- 143 − 101 = 42
The divisor divides every pairwise difference, so the answer is HCF of the differences, which is 42. Check: 59, 101 and 143 all leave remainder 17 when divided by 42.
The differences also have other factors. 21 divides 42 and 21 > 17, so 21 works too, but it is not the largest. A divisor such as 14 fails, because the remainder 17 is not less than 14. For three numbers, use the HCF of the two consecutive differences, since the third difference is their sum.
Finding the number (LCM problems)
Same remainder with every divisor
Find the smallest number that leaves remainder 3 when divided by 4, 6 and 10. The number minus 3 must be a common multiple of 4, 6 and 10. LCM(4, 6, 10) = 60, so the smallest number is 60 + 3 = 63. All valid numbers are 60t + 3 for t = 0, 1, 2, .... Use t = 0 only if the question allows 3 itself. Remember that 3 is smaller than the divisors, so 3 does leave remainder 3.
Same gap between divisor and remainder
Find the smallest number that leaves remainders 5, 7 and 11 when divided by 6, 8 and 12. Compute divisor − remainder:
- 6 − 5 = 1
- 8 − 7 = 1
- 12 − 11 = 1
The gap is always 1, so N + 1 is a common multiple of 6, 8 and 12. LCM = 24, so N = 24 − 1 = 23. In general the answer is LCM − d, and all solutions are LCM·t − d with t ≥ 1.
Extra condition on the number
Find the smallest number that leaves remainder 5 when divided by 8, 12 and 16 and is also divisible by 7. LCM(8, 12, 16) = 48, so candidates are 48t + 5. Now require divisibility by 7. Since 48 ≡ 6 (mod 7), you need 6t + 5 ≡ 0 (mod 7), so 6t ≡ 2 (mod 7). Multiplying by 6, the inverse of 6 modulo 7, gives t ≡ 12 ≡ 5. So t = 5, and N = 48·5 + 5 = 245 = 7 × 35.
In an exam, trying t = 1, 2, 3, ... against the 7-test is usually just as fast and needs no modular arithmetic.
No pattern: combining one divisor at a time
Find the smallest number leaving remainder 3 when divided by 4 and remainder 2 when divided by 5. The gaps are 1 and 3, and the remainders differ, so neither shortcut applies.
- List numbers from the larger divisor: 2, 7, 12, ... (remainder 2 on division by 5).
- Test each against the other condition. 7 leaves remainder 3 when divided by 4, so
N = 7. - Further solutions repeat every LCM(4, 5) = 20: 7, 27, 47, and so on.
Now N ≡ 7 (mod 20) summarizes both conditions. To add a third condition, combine it with this one the same way. The function below automates it.
from math import gcd
def combine(r1, m1, r2, m2):
g = gcd(m1, m2)
step = m1 // g * m2
for k in range(m2 // g):
x = r1 + k * m1
if x % m2 == r2 % m2:
return x % step, step
return None
def solve(pairs):
r, m = pairs[0][0] % pairs[0][1], pairs[0][1]
for r2, m2 in pairs[1:]:
result = combine(r, m, r2, m2)
if result is None:
return None
r, m = result
return r, m
print(solve([(3, 4), (2, 5)])) # (7, 20)
print(solve([(5, 6), (7, 8), (11, 12)])) # (23, 24)
print(solve([(1, 4), (2, 6)])) # NoneThe output (7, 20) means "remainder 7 modulo 20", which is the smallest solution plus the repeat interval. The loop only needs to try m2 // g values, because after that the remainders repeat.
When there is no solution
The last call returns None. A number that leaves remainder 1 when divided by 4 is odd. A number that leaves remainder 2 when divided by 6 is even. Both cannot hold. When the divisors share a factor g, the two remainders must agree modulo g, and here 1 ≢ 2 (mod 2). When the divisors are coprime, a solution always exists.
Quick reference
| Situation | Unknown | Method |
|---|---|---|
| Same remainder `r` for numbers `a, b, c` | Largest divisor | HCF(a−r, b−r, c−r), must exceed `r` |
| Remainders `r1, r2, r3` | Largest divisor | HCF(a−r1, b−r2, c−r3), must exceed each remainder |
| Same unknown remainder | Largest divisor | HCF of pairwise differences |
| Same remainder `r` for divisors | Smallest number | LCM + r |
| Same gap `d = divisor − remainder` | Smallest number | LCM − d |
| Mixed remainders, coprime divisors | Smallest number | Step by the larger divisor, then add LCM |
Common traps
- Adding
rwhen the gap pattern applies, or subtractingdwhen the remainder pattern applies. Check one divisor by direct division before committing. - Skipping the check that the divisor exceeds the remainder.
- Subtracting the same remainder from every number when the remainders actually differ.
- Reporting the LCM-based value when the question asks for the smallest number greater than some bound. Take
LCM·t ± cand choose the firsttthat beats the bound. - Treating "leaves remainder 0" as a special case. It is the same method with
r = 0: the answer is the HCF or LCM itself.
Exercise
Find the largest number that divides 1305, 4665 and 6905 leaving the same remainder in each case.
Show answer
Take the differences: 4665 − 1305 = 3360 and 6905 − 4665 = 2240. HCF(3360, 2240) = 1120, because 3360 = 1.5 × 2240 and the HCF of 3360 and 2240 is 1120. Check: 1305 = 1120 + 185, 4665 = 4·1120 + 185, 6905 = 6·1120 + 185. The common remainder is 185, which is less than 1120, so the answer is 1120.
Exercise
Find the smallest number that leaves remainders 1, 2 and 3 when divided by 4, 5 and 6, and then give the next larger number with the same property.
Show answer
The gaps are 4 − 1 = 3, 5 − 2 = 3 and 6 − 3 = 3. LCM(4, 5, 6) = 60, so the smallest number is 60 − 3 = 57. The next one adds the LCM: 57 + 60 = 117. Check 57: 57 = 14·4 + 1, 57 = 11·5 + 2, 57 = 9·6 + 3.
Exercise
A number leaves remainder 2 when divided by 6 and remainder 4 when divided by 9. Does such a number exist? If so, find the smallest one.
Show answer
gcd(6, 9) = 3, and the remainders 2 and 4 are not equal modulo 3 (2 and 1). So no such number exists. Check: a number leaving remainder 2 on division by 6 leaves remainder 2 on division by 3, while one leaving remainder 4 on division by 9 leaves remainder 1 on division by 3. These conflict.