How many positive integers are there that are smaller than 10000 have the following properties?
See also:
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
Also @Kenneth Tan For Lemma 1,I notice there is a bijection formed here. More intuitively speaking, the first digit can be 1mod, 2mod or 0mod. So, the last k digits can be all possible permutations as they can just sum up to fit 0mod.Just like how a key and lock fits.
We utilize the second condition-it contains neither the digits 1 , 2 , 3 first.
With the bound that the positive integer should be smaller than 1 0 0 0 0 , it is obvious that the maximum number of digits is 4 .
The first, second, third and fourth digit can be 0 , 4 , 5 , 6 , 7 , 8 , having 7 possible choices in each slot.
So, the number of integers which contains neither the digits 1 , 2 , 3 smaller than 1 0 0 0 0 = 7 4 − 1 = 2 4 0 0 .
The act of taking away 1 is removing the number 0 off the list( 0 is not positive integer!).
Now, the difficult part is deducing the multiples of 3 among them and hence deducting the number of them from 2 4 0 0 .
By divisibility rule , the sum of digits of a multiple of 3 is also a multiple of 3 .
We note that the digits can only be 0 , 4 , 5 , 6 , 7 , 8 , 9
Now, we are finding multiples of 3 using the sum of 0 , 1 , 2 four times.
Only the following combinations are possible:
0 + 0 + 0 + 0 , 0 + 0 + 1 + 2 , 0 + 1 + 1 + 1 , 0 + 2 + 2 + 2 , 1 + 2 + 1 + 2
For 0 + 0 + 0 + 0 , the number of integers are 3 ⋅ 3 ⋅ 3 ⋅ 3 − 1 = 8 0 (0 is not a positive integer!)
For 0 + 0 + 1 + 2 , the number of integers are 3 ⋅ 3 ⋅ 2 ⋅ 2 ⋅ 2 ! 4 ! = 4 3 2
For 0 + 1 + 1 + 1 , the number of integers are 3 ⋅ 2 ⋅ 2 ⋅ 2 ⋅ 3 ! 4 ! = 9 6
For 0 + 2 + 2 + 2 , the number of integers are 3 ⋅ 2 ⋅ 2 ⋅ 2 ⋅ 3 ! 4 ! = 9 6
For 1 + 2 + 1 + 2 , the number of integers are 2 ⋅ 2 ⋅ 2 ⋅ 2 ⋅ 2 ! ⋅ 2 ! 4 ! = 9 6
Note: the number of integers here already include permutations .
So, the number of multiples of 3 within the list = 8 0 + 4 3 2 + 9 6 + 9 6 + 9 6 = 8 0 0
∴ the number of integers meeting our requirements = 2 4 0 0 − 8 0 0 = 1 6 0 0
@Kenneth Tan Do you notice that 8 0 0 = 3 1 ( 2 4 0 0 ) , so the number of multiples of 3 is 3 1 of the number of integers in the original list. Is that a coincidence?
Log in to reply
Yes, I did notice that, and in fact, that is not a coincidence. It can be shown that the number of multiples of 3 in the list that are smaller than 1 0 x is M ( x ) = 3 7 x − 1 and since 7 x − 1 is also precisely the number of integers in the original list that are smaller than 1 0 x , if we divide M ( x ) by that we would always get the beautiful result 3 1 7 x − 1 M ( x ) = 3 1 Nice solution using modular arithmetic by the way!
Log in to reply
@Kenneth Tan. Haha thanks. The reason I am able to come up with modular arithmetic solution is because I have a problem pretty similar in terms of employing modular of 3. If you are interested, you can attempt it here .
Problem Loading...
Note Loading...
Set Loading...
Let's call numbers that are multiples of 3 but don't contain the digits 1 , 2 or 3 anti-threes .
We shall first count the number of anti-threes in the range 1 to 9999.
First notice that for any 10 consecutive non-negative multiples of 3, the units digit cycles through 3 , 6 , 9 , 2 , 5 , 8 , 1 , 4 , 7 , 0 , each number from 0 to 9 all appear once.
And also notice that for any 100 consecutive non-negative multiples of 3, each digit sequence 00 to 99 all appear once in the last two digits.
In fact, this idea can be generalized, we have this lemma:
The number of digit sequences from k 0s 0 0 … 0 to k 9s 9 9 … 9 that don't contain 1 , 2 or 3 is 7 k (this is because if you create such sequence using k digits, you can only choose one of the 7 digits 0 , 4 , 5 , 6 , 7 , 8 , 9 for each of the k places, the number of ways to do this is k times 7 × 7 × … × 7 = 7 k )
Therefore, for 1 0 k consecutive non-negative multiples of 3, 7 k of them don't contain the digits 1 , 2 or 3 in their last k places, and as long as the 1 s, 2 s and 3 s don't appear in any other place other than the last k places, we know that out of these 1 0 k numbers, exactly 7 k of them are anti-threes .
As a direct implication of corollary 1 :
(1) If we have 1 0 consecutive non-negative multiples of 3, where none of them have 1 , 2 or 3 in all other places except in the units, then 7 of these 1 0 numbers are anti-threes .
(2) If we have 1 0 0 consecutive non-negative multiples of 3, where none of them have 1 , 2 or 3 in all other places except in the units and the tens, then 7 2 = 4 9 of these 1 0 0 numbers are anti-threes .
(3) If we have 1 0 0 0 consecutive non-negative multiples of 3, where none of them have 1 , 2 or 3 in all other places except in the units, the tens and the hundreds, then 7 3 = 3 4 3 of these 1 0 0 0 numbers are anti-threes .
Okay, we now partition the numbers from 1 to 9999 into intervals and count the number of anti-threes in each of them (notation wise, we assume the intervals only contain integers): 2 anti-threes: { 6 , 9 } [ 1 , 9 ] 0 anti-threes [ 1 0 , 3 9 ] 7 anti-threes [ 4 0 , 6 9 ] 7 anti-threes [ 7 0 , 9 9 ] 0 anti-threes [ 1 0 0 , 3 9 9 ] 49 anti-threes [ 4 0 0 , 6 9 9 ] 49 anti-threes [ 7 0 0 , 9 9 9 ] 0 anti-threes [ 1 0 0 0 , 3 9 9 9 ] 343 anti-threes [ 4 0 0 0 , 6 9 9 9 ] 343 anti-threes [ 7 0 0 0 , 9 9 9 9 ]
( Red intervals contain 10 consecutive multiples of 3 which don't contain 1 , 2 or 3 in its tens place, hence (1) applies. Orange intervals on the other hand contain 100 consecutive multiples of 3 which don't contain 1 , 2 or 3 in its hundreds place, hence (2) applies. Green intervals contain 1000 consecutive multiples of 3 which don't contain 1 , 2 or 3 in its thousands place, hence (3) applies)
The total number of anti-threes from 1 to 9999 is 2 + 7 + 7 + 4 9 + 4 9 + 3 4 3 + 3 4 3 = 8 0 0 .
Finally, the number of integers from 1 to 9999 that don't contain 1 , 2 or 3 is 7 4 − 1 = 2 4 0 0 (there are only 7 ways to choose digits for each of the 4 places, subtracting 1 to exclude 0). These 2 4 0 0 which don't contain 1 , 2 or 3 are comprised of integers that are multiples of 3 (they are anti-threes , there's 8 0 0 of them), and integers that are not multiples of 3 (which is what we are looking for).
Therefore, the total number of positive integers that are not multiples of 3 and contains neither the digits 1 , 2 or 3 is 2 4 0 0 − 8 0 0 = 1 6 0 0 .