This question came up recently:
John III, the third king of Johnland was very angry with John II, who killed the founder of Johnland, the beloved John I. By his new law the digit $2$ was forbidden to use. The numbers were listed as $1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 14, $$ 15, 16, 17, 18, 19, 30, 31, 33, \dots $ What was the $2021$st number in this new system?
I then came up with this:
Sol.:
First, I studied how many numbers would be ‘skipped’ in the system within a power of 10;
100: 0
101: 1
102: 20
103: 300
104: 4000
105: 50000
The pattern is quite clear.
Skipped numbers before 2021st number: 300 x 2 + 1 x 2 + 0 x 1 = 602.
However, in 602 there are some skipped numbers:
(300 x 2 + 1 x 2 + 0 x 1) + (20 x 6 + 0 x 2) = 602 + 120
Also in 120 there are some more:
(300 x 2 + 1 x 2 + 0 x 1) + (20 x 6 + 0 x 2) + (20 x 1 + 1 x 2) = 602 + 120 + 22
And in 22:
(300 x 2 + 1 x 2 + 0 x 1) + (20 x 6 + 0 x 2) + (20 x 1 + 1 x 2) + (1 x 2 + 0 x 2) = 602 + 120 + 22 + 2
There are none in two.
From there I didn't know what to do with myself and just got the answer in python, but that's cheating, so I would like to know how I can hope to solve this question with pure maths.
Cheers!