Let . How many elements of are divisible by or by ?
Choose inclusion–exclusion, and read "or" inclusively. Let be the multiples of in and the multiples of . "Divisible by or " means , and
The subtraction matters: numbers such as , , are in both lists and must not be counted twice.
Count the multiples of 2. Use — multiples up to minus those up to (the numbers below the start of the range):
(The excluded ones are and ; the list runs .)
Count the multiples of 5.
(The list is , and itself is inside the range.)
Count the overlap. A number divisible by both and is divisible by :
Apply the formula.
Cross-check with the complement. The set has elements. Numbers coprime to in a block of consecutive integers number (those ending in ); from to there are full decades – minus... more simply, the count of numbers ending in between and is (from then four per decade for the decades –: ). Then , matching.
Need to solve a different problem like this? Open the solver →