TITLE: Or/Not Conditions in Number Theory
QUESTION [6 upvotes]: How many positive integers, not exceeding 100, are multiples of 2 or 3 but not 4?
Hello, I was wondering how to solve problems like these. My thoughts are to count the number that are multiples of 2 but not 4, multiples of 3 but not 4, and then multiples of 6 but not 4, then use Principle of Inclusion and Exclusion as follows:
$$\left\lfloor \frac{100}{2} \times \frac{1}{2} \right\rfloor + \left\lfloor \frac{100}{3} \times \frac{3}{4} \right\rfloor - \left\lfloor \frac{100}{6} \times \frac{1}{2} \right\rfloor = 42,$$
but I am unsure as to if this is a valid solution. Can anybody confirm/deny that I am using Principle of Inclusion and Exclusion properly? Thanks!

REPLY [2 votes]: It sounds correct, but it needs unpacking.
$$\frac{100}{2} \times \frac{1}{2} = \frac{100}{4} = 25$$
which gives us the 25 singly even numbers. This is below what we think the answer is, but it's a good first step.
$$\frac{100}{3} \times \frac{3}{4} = \frac{300}{12} = 25$$
Adding the two intermediate results so far brings us to 50, which is above what we think the answer is.
Okay, sorry, I'm just confused by what you're getting at here. Clearly you know that 50 is an overcount, which is why you also have
$$ -\left\lfloor \frac{100}{6} \times \frac{1}{2} \right\rfloor = -\left\lfloor \frac{25}{3} \right\rfloor = -8$$
and that adjustment brings us to what we think is the right result. But I just don't understand what this adjustment is adjusting for. I really need to get at this answer a different way before I get too hopelessly confused by this deceptively simple problem.
I verify that the $n$th singly even number is $4n - 2$. So the 25th singly even number is 98. This obviously excludes the multiples of 4, so we only need to account for the odd multiples of 3 now.
The $n$th odd multiple of 3 is $6n - 3$. So the 17th odd multiple of 3 is 99. Then 25 + 17 = 42.
So you got the right answer this time, but your method might not give the right answer for similar problems.
Some mathematicians seems to arrive at the most elegant solution as if by divine inspiration. But many of them just don't tell you about the inelegant solutions they came up first, much less the outright dead ends.