Multiple Counting
Counting how many numbers in a range satisfy a divisibility condition is pure floor arithmetic. In [1, N], the count of multiples of k is floor(N/k); in a general range [A, B] it is floor(B/k) − floor((A−1)/k). For "divisible by a OR b" you must avoid double counting the numbers divisible by both, which gives the inclusion–exclusion formula floor(N/a) + floor(N/b) − floor(N/LCM(a,b)). For "divisible by NEITHER", subtract that OR-count from N (complementary counting). "Exactly one of a, b" is the OR-count minus twice the both-count, or equivalently the two single-only pieces added. The CAT favourite is mixing these: "how many numbers up to 1000 are divisible by 2 or 3 but not 5". Build it in layers — compute each floor term, plug into inclusion–exclusion, then subtract or filter. Always read whether the range is inclusive and whether 0 is excluded; CAT ranges almost always start at 1.
✅ Solved examples
✏️ Practice — try these, take hints as needed
📝 Topic test — 8 questions
Auto-graded with full solutions; saved to your dashboard. Use the calculator and formula sheet (top-right) any time.
Formula Reference Sheet
Counting in a range
| Multiples of k in [1, N] | floor(N / k) |
|---|---|
| Multiples of k in [A, B] | floor(B/k) − floor((A−1)/k) |
| Common multiples of a, b in [1, N] | floor(N / LCM(a, b)) |
| kth common multiple of a, b | k × LCM(a, b) |
| nth multiple of k | n × k |
Inclusion–exclusion (divisibility)
| Divisible by a OR b | floor(N/a) + floor(N/b) − floor(N/LCM(a,b)) |
|---|---|
| Divisible by a AND b | floor(N / LCM(a, b)) |
| Divisible by NEITHER a nor b | N − [floor(N/a) + floor(N/b) − floor(N/LCM)] |
| Three sets a, b, c (OR) | Σfloor(N/x) − Σfloor(N/LCM pairs) + floor(N/LCM(a,b,c)) |
| Exactly one of a, b | [floor(N/a) − floor(N/LCM)] + [floor(N/b) − floor(N/LCM)] |