ExamSaathi learning library · Government exams · SSC CGL quantitative foundations; published syllabus labelled 2024 · Quantitative aptitude
Counting multiples in a range: divisible by one number, both or either
Count how many numbers up to N, or in a range from one number to another, are multiples of k, then use the LCM and the union rule to count numbers divisible by both, either, neither or exactly one of two divisors, with a three-divisor case and numbers that leave a given remainder.
Status: original pilot lesson. Teacher review is pending. It is not a complete course or official exam material.
You will learn to
- Count the multiples of k from 1 to N as the whole-number part of N / k, and the multiples in a range from A to B by subtracting two such counts.
- Find how many numbers in a range are divisible by both of two numbers by counting the multiples of their LCM, which is not always their product.
- Use the union rule n(A) + n(B) - n(both) to count numbers divisible by either of two divisors, by neither, or by exactly one.
- Extend counting multiples to three divisors, and count the numbers in a range that leave a given remainder on division.
Before you start
Here k is always a positive whole number (never 0). A multiple of k is k times a counting number, so the multiples of 9 are 9, 18, 27 and so on. Saying that n is divisible by k means exactly the same as saying that n is a multiple of k. Throughout this lesson, [N / k] means the whole-number part of N / k: divide, then drop the remainder. For instance, [100 / 7] = 14, because 100 = 7 x 14 + 2. The sign x stands for multiplication, so unknown numbers get letters such as n, k and t. You will need the LCM of two or three numbers; finding it, along with divisibility tests and counting factors, belongs to other lessons and is not repeated here. In this lesson a range such as 'from 40 to 90' includes both of its end numbers; the word 'between' is avoided, and any question that uses it must say whether the end numbers count.
The core rule: multiples of one number
Up to N, the multiples of k are k x 1, k x 2, k x 3 and so on, stopping at k x q, where q is the largest whole number for which k x q is not more than N. That stopping point q is [N / k], so there are [N / k] multiples of k from 1 to N. From 1 to 250 there are [250 / 8] = 31 multiples of 8: the last is 8 x 31 = 248, and the next, 256, is too large. For a range from A to B, count the multiples up to B and take away the multiples that come before A: the count is [B / k] - [(A - 1) / k]. Writing A - 1 instead of A matters whenever A is itself a multiple of k. A second way gives a useful check. Find the first multiple in the range, k x s, and the last, k x q. Then the count is q - s + 1, where the + 1 is there because both the first and the last are counted. From 40 to 90, the multiples of 6 run from 42 = 6 x 7 to 90 = 6 x 15, giving 15 - 7 + 1 = 9, and the subtraction agrees: [90 / 6] - [39 / 6] = 15 - 6 = 9.
Both, either, neither and exactly one
Fix a range and two divisors a and b. Let A be the numbers in the range divisible by a, and B the numbers divisible by b. A number is divisible by both a and b exactly when it is a multiple of LCM(a, b), so the 'both' count is a count of multiples of the LCM. The product a x b works only when a and b share no factor other than 1: for 6 and 9 the LCM is 18, not 54. 'Either' here means divisible by a, by b or by both, that is, by at least one of them; these numbers form the union of A and B. Adding n(A) and n(B) counts every 'both' number twice, so n(either) = n(A) + n(B) - n(both). The other groups follow from it: neither = total - n(either), only a = n(A) - n(both), and exactly one = n(A) + n(B) - 2 x n(both). From 1 to 100 with a = 6 and b = 9: n(A) = 16, n(B) = 11 and n(both) = [100 / 18] = 5. So 16 + 11 - 5 = 22 numbers are divisible by 6 or 9, 78 by neither, and 16 + 11 - 10 = 17 by exactly one.
A further case: three divisors and given remainders
For three divisors a, b and c, add the three single counts, take away the three pair counts and add back the count for all three: n(a or b or c) = n(a) + n(b) + n(c) - n(a and b) - n(b and c) - n(a and c) + n(all three). Every pair count uses the LCM of that pair, and the last term uses the LCM of all three. The add-back is needed because a number divisible by all three is added three times and then taken away three times, which would leave it out altogether. Numbers that leave remainder r on division by k, where r is a whole number from 0 up to k - 1, have the form k x t + r: they are r, r + k, r + 2k and so on, spaced k apart. Find the first and the last of them inside the range; the count is (last - first) / k + 1. From 1 to 100, the numbers that leave remainder 3 on division by 7 run from 3 to 94, so there are (94 - 3) / 7 + 1 = 14 of them. When n leaves the same remainder r on division by both a and b, n - r is a multiple of both, so it is a multiple of LCM(a, b).
Common mistakes
Rounding N / k up: 250 / 8 = 31.25 gives 31 multiples of 8, and even 1,000 / 13, about 76.9, gives only 76 multiples of 13. Taking away [A / k] in place of [(A - 1) / k] when the range starts on a multiple, which loses that first multiple. Adding an extra 1 to [B / k] - [(A - 1) / k], which gives one number too many; the + 1 belongs only to the first-and-last method. Using a x b for the 'both' count when a and b share a factor. Forgetting to take away the 'both' group when counting 'either', or taking it away only once when counting 'exactly one'. Leaving out the add-back for numbers divisible by all three divisors. In remainder questions, leaving out the first member of the list: 3 itself leaves remainder 3 on division by 7, because 3 = 7 x 0 + 3.
A routine for counting questions
1. Write down the range and the divisors, and note that both end numbers count; from A to B there are B - A + 1 numbers in all. 2. For each divisor k, find [N / k], or [B / k] - [(A - 1) / k] for a range from A to B. 3. For 'both', find the LCM first and count its multiples. 4. Either = n(A) + n(B) - n(both); neither = total - either; exactly one = either - both. 5. For three divisors, add the singles, take away the pairs and add back the triple. 6. For remainder r on division by k, find the first and last numbers of the form k x t + r in the range and use (last - first) / k + 1. 7. Test the method on a short range, say 1 to 30, by writing the numbers out.
Worked examples
Raffle tickets at a school fair in Jaipur are numbered from 150 to 600, both included. Every ticket whose number is a multiple of 7 wins a small prize. How many tickets win a prize?
- Multiples of 7 up to 600: 600 = 7 x 85 + 5, so [600 / 7] = 85.
- Multiples of 7 below the range, that is up to 149: 149 = 7 x 21 + 2, so [149 / 7] = 21.
- Winning tickets = 85 - 21 = 64.
- Check with the first and last winners: 154 = 7 x 22 and 595 = 7 x 85, so the count is 85 - 22 + 1 = 64.
Answer: 64 tickets win a prize.
A housing society in Pune has 600 flats numbered 1 to 600. This week every flat whose number is divisible by 4 gets a water-meter check, and every flat whose number is divisible by 6 gets an electricity check. How many flats get at least one check, and how many get neither?
- Divisible by 4: [600 / 4] = 150. Divisible by 6: [600 / 6] = 100.
- Divisible by both: the LCM of 4 and 6 is 12, and [600 / 12] = 50. The product 4 x 6 = 24 would give only 25, because it misses flats such as 12, 36 and 60.
- At least one check: 150 + 100 - 50 = 200.
- Neither: 600 - 200 = 400.
Answer: 200 flats get at least one check, and 400 flats get neither.
A school in Patna gives its 500 students the roll numbers 1 to 500. Every student whose roll number is divisible by 3, 5 or 7 is placed in the sports club. How many students are in the club, and how many are not?
- Single counts: [500 / 3] = 166, [500 / 5] = 100 and [500 / 7] = 71, which add up to 337.
- Pair counts: 3, 5 and 7 share no factors, so the pair LCMs are 15, 21 and 35, and [500 / 15] = 33, [500 / 21] = 23 and [500 / 35] = 14, which add up to 70.
- All three: the LCM is 105, and [500 / 105] = 4.
- In the club: 337 - 70 + 4 = 271.
- Not in the club: 500 - 271 = 229.
Answer: 271 students are in the sports club and 229 are not.
Practice checks
- Seats in an auditorium in Nagpur are numbered from 120 to 500, both included. Every seat whose number is a multiple of 8 has a cushion. How many seats have a cushion?
- How many numbers from 1 to 1,000 are divisible by both 6 and 15?
- From 1 to 400, how many numbers are divisible by exactly one of 5 and 8?
- How many numbers from 100 to 500, both included, leave a remainder of 3 when divided by 4 and also when divided by 6?
- From 1 to 900, how many numbers are divisible by none of 2, 3 and 5?
Sources checked
- SSC CGL Scheme and Syllabus, labelled 2024 — Tier-I Quantitative Aptitude and Tier-II Mathematical Abilities (Computation of whole numbers; relationships between numbers); not verified as the full 2026-cycle syllabus
- OpenStax, Contemporary Mathematics — Section 1.4, the union of two sets as an inclusive OR, the intersection as AND, the complement within a universal set, and the cardinality formula n(A or B) = n(A) + n(B) - n(A and B); used here for the either, neither and exactly-one counts, while the three-divisor rule is an extension of the same idea; mathematical relationships only
- OpenStax, Prealgebra 2e — Section 2.4, a multiple of a number as the product of that number and a counting number, a number divisible by n as a multiple of n, and the multiples of 6 as exactly the numbers that are multiples of both 2 and 3; mathematical relationships only