This is an integer problem of mathematics.
I think this is interesting for you if you are interested in Mathematical Olympiad.
(I'm not good at English so you may not be able to read it smoothly. )
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Math problem related to multiples, digits and three
1. Math problem related to
multiples, digits and three
How many Nabeatsu numbers are
there between 1 and 푁?
2. Before the definition of Nabeatsu
numbers…
Definition:
Let 푛 be a positive integer. Let’s call 풏 contains
digit 3 if and only if there exists a digit of 푛
that is 3.
Let 푎푛 be the 푛-th number that contains 3.
3. Examples 1
The number 푎1 = 3 contains digit 3.
The number 푎2 = 13 contains digit 3.
푎3 = 23.
푎4 = 30.
푎5 = 31.
푎6 = 32.
푎7 = 33.
…
푎13 = 39.
5. What are Nabeatsu numbers?
Definition(Nabeatsu numbers):
A positive integer 푛 is a Nabeatsu number if
and only if 푛 is a multiple of three or 푛
contains digit 3.
This definition is at my discretion.
Sekai no Nabeatsu was a Japanese comedian.
I defined it associated with him.
6. Examples
• 45 is a Nabeatsu number. (It is a multiple of
three. )
• 1399 is a Nabeatsu number. (It is not a
multiple of three, but it contains digit 3. )
• 333 is a Nabeatsu number.
• 256 is not a Nabeatsu number.
7. Question
How many Nabeatsu numbers are there
between 1 and 푁?
Let 퐴(푁) be the answer of the question.
8. For example, there are 퐴 40 = 21 Nabeatsu
numbers between 1 and 40.
1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
31, 32, 33, 34, 35, 36, 37, 38, 39, 40.
Is there any efficient algorithm to calculate the
퐴(푁)?
9. Approach to solve the problem
• Assume that there are 푥 multiples of three
between 1 and 푁.
• Assume that there are 푦 numbers that
contain digits 3 between 1 and 푁.
• Assume that there are 푧 multiples of three
that also contain digits 3 between 1 and 푁.
The answer of the problem is 퐴 푁 = 푥 + 푦 − 푧.
Let’s calculate 푥, 푦 and 푧.
10. Calculate 푥!
There are
푥 =
푁
3
(floor function)
multiples of three between 1 and 푁.
11. Calculate 푦!
How many numbers containing digit 3 are
there between 1 and 푁?
Assume that there are 푦 numbers that don’t
contain digit 3 between 1 and 푁.
It holds that 푦 = 푁 − 푦 , so we will calculate 푦
at first.
I will show you the way of calculating 푦 .
12. For example, let 푁 = 25383.
Then, what is the value of 푦 ?
How many numbers that do not contain
digit 3 in {00001, 00002, … , 25389} ?
Numbers’ form: 0**** or 1****
Each digit * is 0, 1, 2, 4, 5, 6, 7, 8 or 9. But 00000
is not considered. Thus, there are
2 × 94 − 1
numbers in this form.
13. Numbers’ form:
20*** or 21*** or 22*** or 24***
There are
(5 − 1) × 93
numbers in this form.
Since 5 > 3, the term −1 arised.
16. In the same way, if 푁 = 260734397, then
푦 = 2 × 98 + 6 − 1 × 97 + 0 × 96
+ 7 − 1 × 95 + 3 × 94 − 1.
If 푁 = 51048, then
푦 = (5 − 1) × 94 + 1 × 93 + 0 × 92
+ 4 − 1 × 91 + 8 × 90.
17. If the value of 푦 become clear, we can calculate
the value of 푦 = 푁 − 푦 .
18. Calculate 푧!
Claim:
푎푛+1 = 푎푛 + 1 or 4 or 7 or 10 .
Proof:
Case 1-1: 푎푛 =∗∗ ⋯ ∗ 3, each digit ∗ is not 3 and
the end of 푎푛 is neither 299 ⋯ 93 nor 23.
It holds that 푎푛+1 = 푎푛 + 10.
(For example, if 푎푛 = 1283, then 푎푛+1 = 1293 =
푎푛 + 10.)
19. Case 1-2: 푎푛 =∗∗ ⋯ ∗ 3, each digit ∗ is not 3
and the end of 푎푛 is 299 ⋯ 93 or 23.
It holds that 푎푛+1 = 푎푛 + 7.
(For example, if 푎푛 = 1293, then 푎푛+1 =
1300 = 푎푛 + 7.)
20. Case 2-1: 푎푛 =∗∗ ⋯ ∗ 3@@ ⋯ @ or 3@@ ⋯ @,
each digit ∗ is not 3 and at least one digit @ is
not 9.
It holds that 푎푛+1 = 푎푛 + 1.
(For example, if 푎푛 = 13998, then 푎푛+1 =
13999 = 푎푛 + 1.)
21. Case 2-2: 푎푛 =∗∗ ⋯ ∗ 399 ⋯ 9 or 399 ⋯ 9 , and
each digit ∗ is not 3.
It holds that 푎푛+1 = 푎푛 + 4.
(For example, if 푎푛 = 13999, then 푎푛+1 =
14003 = 푎푛 + 4.)
22. Thus, it holds that
푎푛+1 = 푎푛 + 1 or 4 or 7 or 10 . ∎
Thus, it holds that
푎푛+1 ≡ 푎푛 + 1 (mod 3).
Since 푎1 = 3 is a multiple of three,
푎3푛+1 is a multiple of three for 푛 ≥ 0.
23. Thus, it holds that
푧 =
푦 + 2
3
.
Buy the way, it holds that
푦 − 푧 =
2
3
푦 .
(Hint: If 푦 = 3푘 + 1, then 푦 − 푧 =? ? ?. If 푦 = 3푘 + 2,
then 푦 − 푧 =? ? ?. If 푦 = 3푘 + 1, then 푦 − 푧 =? ? ?.)
24. Answer
There are
퐴 푁 = 푥 + 푦 − 푧 =
푁
3
+
2
3
푦
Nabeatsu numbers between 1 and 푁.
I think it is also interesting to make a program
that calculate 퐴 푁 .
I will show you three examples.