math problem

How many positive integers less than 1,001 are divisible by either 2 or 5 or both?

For 2, it’s at least 500.
For 5, it’s at least 200.
For both, it’s at least 100.

So, what is the question trying to ask? The answer is 600.

It seems to me that the answer would be 700.

@intparent it’s 600.

There are (exactly) 500 positive integers ≤ 1000 that are divisible by 2 – those are the integers 2, 4, 6, 8, 10, …, 1000.

There are 200 positive integers ≤ 1000 that are divisible by 5 (5, 10, 15, …, 1000).

But we counted the multiples of 10 twice. We only wish to count them once, so we must subtract off 100 (corresponding to the numbers 10, 20, 30, …, 1000). 500+200-100 = 600.

More generally, this is known as the inclusion-exclusion principle which states that for finite sets A and B, the size of their union is the sum of the sizes of A and B, minus their intersection (|A ∪ B| = |A| + |B| - |A ∩ B|).

Optional:
If any of you are familiar with Euler’s phi function, the answer is also 1000 - φ(1000) = 600.

My daughter is going to love this.

And that is why I said “It seems to me”. I figured someone could explain why that wasn’t right. :slight_smile: That makes sense.

To me, I think it was better to just count 0,2,4,5,6,8 as six digits, multiply them by 10 to get how many are in 100, then multiply by 10 again to get how many in a 1000.

@BeCambridge actually yeah, that works quite nicely here; I totally missed that. Only problem is that it doesn’t really generalize to similar types of problems.

Do you know an example where it fails to work?

@BeCambridge yes, for example, replace “2” with “3” in the original problem.

I think it’s the same concept of patterns (assuming the answer is 470).

From 0-9, the “both” set consists of 0,3,5,6,9 or five digits.
From 10-19, the “both” set consists of 10,12,15(counted ONLY once),18 or four digits.
From 20-29, the “both” set consists of 20,21,24,25,27 or five digits.

So, the pattern here is five,four,five - five,four,five… So there would be 47 in a hundred and 470 in a thousand.

I think this problem requires a zero use of a calculator. When I posted the original problem, it has a consistent pattern for every ten. When 2 is replaced with 3, the pattern becomes 5-4-5 for every 30.

@BeCambridge well not quite - you have the right idea; it is true that the pattern will repeat every 30 (in fact, every 15) but since 1000 is not evenly divisible by 15, you’d likely be off by a little bit and would have to handle 991, …, 1000 separately. The problem becomes more pronounced if I replace “3” and “5” with numbers such as 31 and 77.

Inclusion-exclusion handles it quite nicely:

Answer = (# multiples of 3 ≤ 1000) + (# multiples of 5 ≤ 1000) - (# multiples of 15 ≤ 1000)
= ⌊1000/3⌋ + ⌊1000/5⌋ - ⌊1000/15⌋ (where ⌊x⌋ is x rounded down; i.e. largest integer ≤ x)
= 333 + 200 - 66
= 467

So the answer is 467 instead of 470.