What's in both lists?
Common divisors list
In both lists
divisors(375) = [1, 3, 5, 15, 25, 75, 125, 375]
divisors(825) = [1, 3, 5, 11, 15, 25, 33, 55, 75, 165, 275, 825]
We want the numbers in both lists, and we want a systematic way to find them.
Which list is it enough to walk through, one value at a time?
What this lesson covers
The idea
The common divisors of two numbers are found by checking each divisor in the first list for membership in the second; 1 is always among them.
In both lists
divisors(375) = [1, 3, 5, 15, 25, 75, 125, 375] divisors(825) = [1, 3, 5, 11, 15, 25, 33, 55, 75, 165, 275, 825] We want the numbers in both lists, and we want a systematic way to find them.
Which list is it enough to walk through, one value at a time?
- Just the first list, checking each value in the second
- Every number from 1 to 825
- Neither: guess and check
Walk the first list
Start with an empty list of common divisors. For each divisor in the first list, check whether it is also in the second list. If it is, add it.
Check membership
To find the common divisors, check each divisor in the first list for membership in the second list, and add those that belong. 1 is always among them.
1, 3, 5, 15, 25 and 75 are in the second list; 125 and 375 are not. So the common divisors of 375 and 825 are [1, 3, 5, 15, 25, 75]. Since 1 divides every number, the list of common divisors always has at least one entry, 1.
Notes
Common divisors: start empty; for each divisor of the first number, if it is also a divisor of the second, add it. 1 is always there.
Check yourself
Why can the list of common divisors never be empty?
Walking through divisors(375), which value is NOT added to the common-divisors list?
How many common divisors do 375 and 825 have?
Answer: 6
The common divisors are [1, 3, 5, 15, 25, 75]: 6 of them.
- 1 divides every number, so 1 is always a common divisor — correct. Yes. The list always starts with 1.
- Two numbers always share a prime factor. Not true: 8 and 15 share no prime factor, yet 1 is still common.
- Because the second list is longer. Length has nothing to do with it.
- 125 — correct. Right. 125 does not divide 825, so it is not in the second list.
- 25. 25 divides 825 (825 = 33 × 25), so it is added.
- 15. 15 divides 825 (825 = 55 × 15), so it is added.