3

How many numbers lie in the range of $1331$ and $3113$ (Endpoints Inclusive) such that they are not divisible by $2$ or $3$ or $5$?

I came across this Number System question and was not able to figure out the way to get the answer. At first I thought to separate out the numbers which are divisible by the LCM of $2$, $3$ & $5$ but this will still leave some numbers which will be exclusively divisible by any one of $2$ or $3$ or $5$. Another method I found out to solve these type of questions is by using the Euler's Totient method but I am not aware of this. So can someone please explain a general way to solve these types of question?

General question can be : How many numbers lie in the range of $A$ and $B$ such that they are not divisible by $x$ or $y$ or $z$ and so on?

Ganit
  • 1,689
  • 1
    Find all the numbers divisible by 2, by 3, or by 5 (separately). You will have double counted numbers divisible by 6, 10, or 15. How many numbers is that? – preferred_anon Mar 03 '21 at 11:49
  • @JitendraSingh : Yes – Ganit Mar 03 '21 at 11:51
  • @Ali Okay thanks for informing –  Mar 03 '21 at 11:53
  • 2
    @preferred_anon : i tried your way... Numbers divisible by 2 = 891 Numbers divisible by 3 = 594 and Numbers divisible by 5 = 356 Numbers divisible by 6 = 296 Numbers divisible by 10 = 178 Numbers divisbile by 15 = 119 From here how to proceed? please guide.. – Ganit Mar 03 '21 at 12:05
  • Good question , +1. You can find more details on MathJax either on the MathJax tutorial page, or over here which is being developed specifically for new users. If you need advice for a specific question, then visit the chatroom whose link I gave in the answer below for help. – Sarvesh Ravichandran Iyer Mar 03 '21 at 12:34
  • @Ali I've written up a full argument. Thanks for your reply! – preferred_anon Mar 03 '21 at 14:02

3 Answers3

3

Another approach:

An integer $n$ is not divisible by any of $2$, $3$, and $5$ if and only if $n$ is relatively prime to $30$; and this in turn occurs if and only if $n$ leaves one of the eight remainders: $1, 7, 11, 13, 17, 19, 23, $ or $29$ upon division by $30$.

Because remainders upon division by $30$ occur cyclically: among any $30$ consecutive integers, exactly $8$ will not be divisible by any of $2, 3, 5$.

The interval $1331$ to $3100$ contains $1770=59\cdot 30$ integers. So this interval will contain $59\cdot 8=472$ integers not divisible by any of $2, 3, 5$.

From $3101$ to $3113$, the remainders upon division by $30$ are $11, 12, ..., 23$. Of these, the five with remainders of $11, 13, 17, 19, 23$ will not be divisible by any of $2, 3, 5$.

So the total in the desired interval is $472 + 5=477$ integers not divisible by any of $2, 3, 5$.

paw88789
  • 40,402
  • and this in turn occurs if and only if n leaves one of the eight remainders: 1,7,11,13,17,19,23, or 29 upon division by 30 ==> can you explain this? – Ganit Mar 03 '21 at 14:42
  • 1
    According to the division algorithm, any integer $n$ can be written in the form $n=30q + r$ where the remainder, $r$, satisfies $0\le r < 30$. If $r$ is not relatively prime to $30$, then $n$ will not be relatively prime to $30$ (that is it will have a factor of $2, 3$, or $5$). For example, $417 = 30\cdot 13 + 27$. Thus $417$ has a factor of $3$ since both $30$ and $27$ have a factor of $2$. On the other hand $419 = 30\cdot 13 + 29$. Since $29$ does not have a factor of $2, 3$, or $5$, neither does $419$. – paw88789 Mar 03 '21 at 14:50
  • 1
    +1. This is arguably the best way. I did the same way but from $1320+1$ to $3120$ and resulting math was even simpler : $60\cdot 8 -3 =477$ – cosmo5 Mar 03 '21 at 17:53
2

This is a classic application of the Inclusion-Exclusion Principle.

I will write $a|b$ as a shorthand for "$a$ divides $b$". You want to know how many numbers (between 1331 and 3113) are not divisible by 2, 3, or 5. First I will count the number divisible by either 2, 3, or 5. So let $1331 \le n \le 3113$ (the question does not specify whether the endpoints are included, but at this point it doesn't matter).

We want to count the number of $n$ satisfying:

$2|n$ OR $3|n$ OR $5|n$.

You count 891, 594, 356. This is the first term in the inclusion-exclusion formula. The answer is not just $891+594+356$, because we have double-counted those numbers in the overlap - namely, those numbers such that:

($2|n$ AND $3|n$), OR ($2|n$ AND $5|n$), OR ($3|n$ AND $5|n$)

This group can be simplified to:

$6|n$ OR $10|n$ OR $15|n$

There are 297, 178, 119 in each group. So to remove the double-counted elements, we should take them away from our sum, right?

Well, $(891+594+356) - (297 + 178 + 119)$ is still not the answer because we have removed too many items. To cut a verbose story short, consider those numbers divisible by 2, 3 and 5 (i.e. by 30). Well, We counted them three times in the first counting, and removed them three times in the second counting.

So we have to add them back in, and there are 59 such numbers. So the final answer is

$$891+594+356 - 297-178-119 + 59 = 1306$$

So your final answer is 477, if "between" includes the endpoints for you.

The general question

If $x, y, z$ are coprime numbers, then the general question is exactly the same as above. You just do $$(\lfloor B/x \rfloor - \lfloor A/x \rfloor) + (\lfloor B/y \rfloor - \lfloor A/y \rfloor) + \ldots - (\lfloor B/xy \rfloor - \lfloor A/xy \rfloor) - \ldots + (\lfloor B/xyz \rfloor - \lfloor A/xyz \rfloor) .$$

If they aren't coprime, then i t's slightly different - suppose for example $x=6$, $y=9$, $z=12$. Then "$6|n$ AND $9|n$" is equivalent to $18|n$, not to $54|n$ as you might naively guess.

  • thanks for the reply...the correct answer is 477 and the endpoints are also included... – Ganit Mar 03 '21 at 14:06
  • @Ali I double checked - there are 297 numbers in that range divisible by 6, not 296. The bigger of my two answers is the one with the endpoints included. I've edited to correct. – preferred_anon Mar 03 '21 at 14:09
  • OK got it now...thanks for the help! – Ganit Mar 03 '21 at 14:11
1

By nos I mean numbers.

For total nos between $1331$ and $3113 = 3113-1331 -1 = 1781$ (excluding end nos)

Of $1781$ nos , the nos divisible by $2 = 1781 +1 = 891$ (as the starting no is even so no of even nos is greater than no of odd nos )

now nos which aren't divisible by $2 = 890$.

Of $890$ nos, nos which are divisible by $5$ but don't end in $0 = 1781/10= 178$ (as the nos ending in $0$ are already eliminated)

(for every $10$ nos there is one no divisible by $5$ and not ending in $0$)

so now, nos not divisible $2$ or $5 = 890 -178 = 712 $

now for nos divisible by $3$, take the nos from $1338$ to $3108$ which has $1770$ nos for every $30$ nos , there are $10$ nos divisible by $3$ of which $5$ are also divisible by $2$ and one is divisible by $5$ but not ends in $0$. So for every $30$ nos , $4$ nos are divisible by $3$ but not by $2$ or $5$

so of $1770$ nos there are $59$ sets of $30$ nos . hence $4 * 59 = 236 $ nos are divisible by $3$ but not by $2$ or $5$.

so nos not divisible by $2$ or $3$ or $5$ in given range $712 - 236 = 476$

but we haven't taken $3$ multiples in range $1331$ to $1338$ and $3108$ to $3113$
nos multiple of $3$ in this range is $= 1334$ (even and hence eliminated) , $1335$ (divisible by $5$ and ends in $5$) , $3111$(not eliminated) so $476 - 1 = 475$ .

but i have excluded end nos so adding $2$

$ = 475 + 2 = 477 $.

  • 2
    Just this "nos" bit : many people will be reading your answer, and I'm not sure all of them will know what these are , so you will have to edit your answer and reflect more clarity. Just a simple find-and-replace will get you "numbers" in place of nos. Also, you can use MathJax for the intermediate numbers, I am sure you will do that anyway. I will up vote once I see your final product, kindly call me then. – Sarvesh Ravichandran Iyer Mar 03 '21 at 11:53
  • Okay i will do that thanks for informing @TeresaLisbon –  Mar 03 '21 at 11:54
  • You are ciertamente a little puzzled as to why I am being so specific. The point is, reputation is not meant to be sniffed at entirely, it is a mark of professionalism and integrity in your answers. The effort is not merely in the thought process but also in the presentation of the answer, and the understanding of the other user's capability. That's why we insist that answers be of certain standard in terms of presentation as well. The improvement is marked, but some numbers have yet to be changed to MathJax. I will do that for you. – Sarvesh Ravichandran Iyer Mar 03 '21 at 12:07
  • @TeresaLisbon : Hi, I am also not aware of this MathJax thing as I am not a mathematics student. Is it a different kind of language that we use? can you please guide us to the right source to learn this? thanks ! – Ganit Mar 03 '21 at 12:11
  • @Ali Hi, thanks for asking. We can have an extended conversation. Kindly join this chatroom and type "TeresaLisbon" to let me know that you are there. Also just wait for a minute or two, I will respond. – Sarvesh Ravichandran Iyer Mar 03 '21 at 12:13
  • @JitendraSingh I have made changes, you can see them. By chance, is your primary language Hindi, and not English? I ask because your sentences are slightly broken, that is why. I have given a +1 for the initial edits. – Sarvesh Ravichandran Iyer Mar 03 '21 at 12:13
  • 1
    @TeresaLisbon thanks for doing the changes, yes my primary language is Hindi –  Mar 03 '21 at 12:17
  • 1
    @Ali I guess you can learn more about MathJax on https://math.meta.stackexchange.com/questions/5020/mathjax-basic-tutorial-and-quick-reference. Also if you are satisfied with the answer and understood it you can click on the grey tick. If you have any doubt regarding my answer you can ask on comment section here –  Mar 03 '21 at 12:19
  • 1
    @JitendraSingh अगली बार से ध्यान रखिये, जितनी professional आपके उत्तर होंगे, उतनी आपकी reputation बढ़ेगी । इस लिए आप को पहले से ही अपनी उत्तर को सुधारना है | MathJax का भरपूर इस्तेमाल कीजिये और जितनी हो सके उतनी अच्छी अंग्रेजी में लिखें। इससे आपकी तरक्की होगी। और कोई सवाल या फिर दिक्कत हो तोह हमारे चैटरूम में आ जाइये और पूछिए। (My first language is also not English, first Hindi then Tamil and Kannada. But I still learnt somewhat and got better!) – Sarvesh Ravichandran Iyer Mar 03 '21 at 12:23
  • @JitendraSingh : i have put up a comment in the question. can you please guide me from there? I have worked my solution in response to preferred_anon as he suggested. – Ganit Mar 03 '21 at 12:53
  • @Ali which comment are you talking about - this one "@TeresaLisbon : Hi, I am also not aware of this MathJax thing as I am not a mathematics student. Is it a different kind of language that we use? can you please guide us to the right source to learn this? thanks !" or "@preferred_anon : i tried your way... Numbers divisible by 2 = 891 Numbers divisible by 3 = 594 and Numbers divisible by 5 = 356 Numbers divisible by 6 = 296 Numbers divisible by 10 = 178 Numbers divisbile by 15 = 119 From here how to proceed? please guide" –  Mar 03 '21 at 12:57
  • "@preferred_anon : i tried your way... Numbers divisible by 2 = 891 Numbers divisible by 3 = 594 and Numbers divisible by 5 = 356 Numbers divisible by 6 = 296 Numbers divisible by 10 = 178 Numbers divisbile by 15 = 119 From here how to proceed? please guide" ==> this one... – Ganit Mar 03 '21 at 12:58
  • He said : "Find all the numbers divisible by 2, by 3, or by 5 (separately). You will have double counted numbers divisible by 6, 10, or 15. How many numbers is that?" ==> i did that but i am not able to pick it up. meanwhile i am going through your solution. – Ganit Mar 03 '21 at 12:58
  • Why need to try that way however @Ali you can try the way I mentioned above –  Mar 03 '21 at 12:58
  • Actually the way you said will give you some extra number because some numbers will be common. Just refer my answer you will get how to eradicate those common numbers –  Mar 03 '21 at 13:00