Calculate how many of the numbers are divisible by 11, 23, 29 with range from 2100 & 10000

39 Views Asked by At

I'm trying to solve one exercice but I'm not sure this is the correct answer.

Exercice description:

How many of the numbers between 2100 and 10000 are divisible by 11,23,29.

Here's my solve:

|A| = 909 - 190 = 719
|B| = 434 - 91 = 343
|C| = 343 - 72 = 271

A∩B = 39 - 8 = 31
A∩C = 31 - 6 = 25
B∩C = 14 - 3 = 11

Using:
|A∪B∪C|=|A|+|B|+|C|−|A∩B|−|A∩C|−|B∩C|+|A∩B∩C|.

719 + 343 + 271 - 31 - 25 - 11 + 1
= 1267.

Is this is the right answer?

1

There are 1 best solutions below

0
On BEST ANSWER

Let $d$ be a positive integer.

Given a non-negative integer $r$ let the number of positive integers that are at most $r$ and are multiples of $d$ be $f(r)$, then $f(r) = \lfloor r/d\rfloor$,

Given positive integers $l\leq r$ let $g(l,r)$ be the number of positive integers that are in the range $[l,r]$ and are multiples of $d$, then $g(l,r) = f(r) - f(l-1) = \lfloor r/d \rfloor - \lfloor (l-1)/d \rfloor$.


Given positive integers $d_1,\dots,d_k$ the numbers that are multiples of all $d_i$ are precisely the numbers that are multiples of $\operatorname{lcm}(d_1,\dots,d_k)$.


If we now apply inclusion-exclusion alongside with the previous stuff we get:

Let $l,r$ be positive integers and $d_1,\dots,d_n$ be positive integers, then the number of positive integers in the range $l,r$ that are multiples of at least one of the $d_i$ is

$$ \sum\limits_{S\subseteq \{1,\dots,n\}, S \neq \varnothing} \left ( \lfloor\frac{r}{\operatorname{lcm}(d_i | i \in S)} \rfloor - \lfloor\frac{l-1}{\operatorname{lcm}(d_i | i \in S)} \rfloor \right ) (-1)^{|S|+1}$$

this appears to be the formula being used.