-1
$\begingroup$

How many numbers are there in range 1 to 1000 which contains digits 2 and 3 and divisible 2 and 3?
I know the answer to find count of numbers in range 1 to 1000 which are divisble by 2 and 3. But the above question also asks that those numbers must include digits 2 and 3.
Please genaralise your answer beacuse I want to know the answers when there are more or different digits. Like find count of numbers in range 1 to 1000000 which contains digit 5,2,7,8 and divisible by 5,2,7,8.

$\endgroup$
  • $\begingroup$ You're looking for a multiple of 6 whose decimal representation has a 2 and a 3. There are no such one or two digit numbers. For three digit numbers, you must have $2+3+x$ divisible by 3, where $x$ is the third digit. So $x$ is 1, 4, or 7. But you also need the number to be even. Hence... ? $\endgroup$ – symplectomorphic Jul 4 '16 at 8:11
  • 1
    $\begingroup$ As I see, there's probably no simple way to generalise. Counting is probably the simplest way to do it $\endgroup$ – Aditya De Saha Jul 4 '16 at 8:26
  • $\begingroup$ I think the problem was specific and wanted you to rely on the fact that the third digit must be 1, 4 or 7 (else it's not divisible by 3) and the number must end in 4 (else it's not divisible by 2). This is certainly not extendable to general cases. $\endgroup$ – fleablood Jul 6 '16 at 5:59
  • $\begingroup$ Here is the source of the problem: cs.stackexchange.com/q/60267/755 $\endgroup$ – D.W. Jul 10 '16 at 16:58
2
$\begingroup$

$3$-digit numbers containing $[2,3]$ and divisible by $[2,3]$:

  • $132$
  • $234$
  • $312$
  • $324$
  • $342$
  • $372$
  • $432$
  • $732$

$6$-digit numbers containing $[2,5,7,8]$ and divisible by $[2,5,7,8]$:

  • $175280$
  • $258720$
  • $357280$
  • $387520$
  • $538720$
  • $567280$
  • $572880$
  • $580720$
  • $728560$
  • $735280$
  • $752080$
  • $758240$
  • $785120$
  • $807520$
  • $857920$
  • $875280$
  • $877520$
  • $958720$
$\endgroup$
  • $\begingroup$ I am not looking for specifically this case. Can you please generalise your answer? If you have to find how many numbers are there in range 1 to 1000000000 having digits a,b,c and divisible by digits a,b,c. where 1<=a,b,c<=9 and a!=b!=c $\endgroup$ – Mike Jul 4 '16 at 8:25
  • $\begingroup$ @Mike: That depends on the values of $[a,b,c]$. $\endgroup$ – barak manos Jul 4 '16 at 8:28
1
$\begingroup$

A general exact answer seems difficult, but here's a way to get a good estimate that readily generalises. Divisibility by $2$ constrains the last digit; divisibility by $3$ doesn't constrain any digits and can be treated as roughly independent of the other constraints. Thus, if we treat the problem probabilistically, we have the events $D_i$ of containing digit $i$ and $E_i$ of divisibility by $i$, we're looking for $\textsf{Pr}(D_2\cap D_3\cap E_2\cap E_3)$, and we can treat $E_3$ as independent of the three other events and $E_2$ as dependent with $D_2$ and $D_3$ only through the last digit. Then

\begin{align} \def\pr#1{\textsf{Pr}\left(#1\right)} \pr{D_2\cap D_3\cap E_2\cap E_3} &=\pr{D_2\cap D_3\cap E_2}\pr{E_3} \\ &= \frac13\left(\pr{D_2\cap E_2}+\pr{D_3\cap E_2}-\pr{(D_2\cup D_3)\cap E_2}\right) \\ &= \frac13\left(\frac12\left(1-\frac45\left(\frac9{10}\right)^{n-1}\right)+\frac12\left(1-\left(\frac9{10}\right)^{n-1}\right)-\frac12\left(1-\frac45\left(\frac8{10}\right)^{n-1}\right)\right) \\ &= \frac16\left(1-\frac{2\cdot9^n-8^n}{10^n}\right)\;, \end{align}

where $n$ is the number of digits, so the expected count of such numbers would be

$$ \frac16\left(10^n-2\cdot9^n+8^n\right)\;. $$

In your case, with $n=3$, this is

$$ \frac16\left(10^3-2\cdot9^3+8^3\right)=9\;, $$

in reasonable agreement with the fact that barak manos counted $8$.

For the case of $5$, $2$, $7$ and $8$, divisibility by $5$ and $2$ simply means that the number ends in a $0$; this is equivalent to asking how many numbers with $n-1$ digits contain $5$, $2$, $7$ and $8$ and are divisible by $7$ and $4$. Again divisibility by $7$ is independent since $7$ is coprime to the base $10$, but now the calculation is slightly more involved since divisibility by $4$ constrains the last $2$ digits and you need to perform inclusion-exclusion on all $4$ digit values that should be present. Still, the ingredients are all in the calculation above.

$\endgroup$
1
$\begingroup$

$\newcommand{\angles}[1]{\left\langle\,{#1}\,\right\rangle} \newcommand{\braces}[1]{\left\lbrace\,{#1}\,\right\rbrace} \newcommand{\bracks}[1]{\left\lbrack\,{#1}\,\right\rbrack} \newcommand{\dd}{\mathrm{d}} \newcommand{\ds}[1]{\displaystyle{#1}} \newcommand{\expo}[1]{\,\mathrm{e}^{#1}\,} \newcommand{\half}{{1 \over 2}} \newcommand{\ic}{\mathrm{i}} \newcommand{\iff}{\Longleftrightarrow} \newcommand{\imp}{\Longrightarrow} \newcommand{\Li}[1]{\,\mathrm{Li}} \newcommand{\ol}[1]{\overline{#1}} \newcommand{\pars}[1]{\left(\,{#1}\,\right)} \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}} \newcommand{\ul}[1]{\underline{#1}} \newcommand{\root}[2][]{\,\sqrt[#1]{\,{#2}\,}\,} \newcommand{\totald}[3][]{\frac{\mathrm{d}^{#1} #2}{\mathrm{d} #3^{#1}}} \newcommand{\verts}[1]{\left\vert\,{#1}\,\right\vert}$ We are looking for numbers of the form $\ds{100\,a +10\,b + c}$, where $\ds{a,b \in \braces{0,1,\ldots,9}}$ and $\ds{c \in \braces{1,2,\ldots,9}}$which satisfy the following conditions:

  1. $\ds{c}$ is an even number and $3 \mid \pars{a + b + c}$.
  2. If $\ds{\color{#f00}{c} \not= \color{#f00}{2}}$, then $\ds{a + b = 5}$. It leaves us with $\ds{c = 4}$ because $\ds{3 | \pars{5 + 0}}$,$\ds{3|\pars{5 + 6}}$ and $\ds{3|\pars{5 + 8}}$ are false.
  3. If $\ds{\color{#f00}{c} = \color{#f00}{4}}$, it obviously leaves us with $\ds{\ul{two}}$ numbers: $\ds{\color{#f00}{234}}$ and $\ds{\color{#f00}{324}}$.
  4. If $\ds{\color{#f00}{c} = \color{#f00}{2}}$, $\ds{a + b + 2 = 3p}$ where $\ds{p}$ is an integer $\ds{~\pars{\mbox{for the time being,}\ 1 \leq p \leq 6}~}$. Because $\ds{a = 3}$ or $\ds{b = 3}$, one of them is equal to $\ds{3p - 2 -3 = 3p - 5}$. Note that $\ds{3p - 5 \not= 3}$. \begin{align} &\mbox{But}\quad 0 \leq 3p - 5 \leq 9\quad\imp\quad {5 \over 3} \leq p \leq {14 \over 3}\quad\imp\quad p \in \braces{2,3,4} \\ &\imp\quad 3p - 5 \in \braces{1,4,7}\ \mbox{which yields}\ 3\times 2 = 6\ \mbox{numbers}:\ \left\lbrace\begin{array}{l} \ds{\color{#f00}{132}} \\ \ds{\color{#f00}{312}} \\ \ds{\color{#f00}{342}} \\ \ds{\color{#f00}{432}} \\ \ds{\color{#f00}{372}} \\ \ds{\color{#f00}{732}} \end{array}\right. \end{align}
    There are $\ds{\color{#f00}{8}}$ numbers which satisfy the OP conditions. Namely, $$ \begin{array}{|c|}\hline\mbox{}\\ \ds{\quad% \color{#f00}{132},\color{#f00}{234},\color{#f00}{312},\color{#f00}{324},\color{#f00}{342},\color{#f00}{372},\color{#f00}{432},\color{#f00}{732} \quad} \\ \mbox{}\\ \hline \end{array} $$
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.