1

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!

Jessie
  • 1,502
Arale
  • 181
  • Count how many integers $n\in[1,2021]$ contain the digit $2$ and remove them (as a first step) – user170231 Mar 17 '21 at 18:38
  • @user170231, count?! how do I go through thousands of numbers? – Arale Mar 17 '21 at 18:40
  • 2
    Inclusion-Exclusion. Of the 100 numbers between 1 and 100, inclusive, how many of them will be skipped. The numbers 20 thru 20 inclusive, and the other 9 numbers 2,12,32,...,92. Therefore, the # of unskipped numbers between 1 and 100 inclusive is 100 - 20 - 9. The same logic extends upwards; you just have to be very careful in your enumeration. – user2661923 Mar 17 '21 at 18:40
  • 2
    "Count" doesn't necessarily mean one at a time. There's a whole discipline devoted to counting things where the one-at-a-time approach is not practical. – user170231 Mar 17 '21 at 18:41
  • 1
    Hint you might find it helpful (as in the original) to think of it as an analog odometer that is faulty, viz. each digit wheel skips the digit $2,,$ so counts $9$ units as $,0,1,3,4,\cdots,9,,$ then carries to the left wheel, so it is the same as a radix $9$ odometer, except digit $3$ mean $2,,$ $4$ means $3,\ldots 9$ means $8.\ \ $ – Bill Dubuque Mar 17 '21 at 21:32
  • There are likely many more dupes (I stopped looking after those two). – Bill Dubuque Mar 17 '21 at 21:45

2 Answers2

4

First convert $2021$ base ten to base nine, thus $2685$.

Now map the digits from the base nine representation so that $2$ is excluded instead of $9$, to wit $(0,1,2,3,4,5,6,7,8)\to(0,1,3,4,5,6,7,8,9)$. Thus $2685\to\color{blue}{3796}$.

Oscar Lanzi
  • 48,208
4

I remember a solution to an old olympiad problem which I had seen in Titu's Number theory book.

It is a really cool solution and I have remembered it ever since, I think we can apply it here.

As the digit 2 is skipped, we can think of it as counting in base 9 , where every digit after 2, corresponds to the digit before it, ie. 0-> 0, 1->1, 3->2 , 4 -> 3 ....9 - > 8,

So when we look at it like this, then 11 corresponds to 10, 13 corresponds to 11 and so on...

So the $2021^{th}$ number will correspond to 2021 in base 9, ie. 2685, but as per our rule, that is $3796$

Aditya_math
  • 1,887
  • 2
    Wow! I never expected this question to be related to something coming from an Olympiad! Elegant! +1 – Arale Mar 17 '21 at 19:04
  • Thanks, I actually found the question after some time, it was AMC 12A/2005, not really an Olympiad per se but still really cool – Aditya_math Mar 17 '21 at 19:46
  • 1
    More concretely (as in the original) we can think of it as an analog odometer that is faulty, viz. each digit wheel skips the digit $2,,$ so counts $9$ units as $,0,1,3,4,\cdots,9,,$ then carries to the left wheel, so it is the same as a radix $9$ odometer, except digit $3$ mean $2,,$ $4$ means $3,\ldots 9$ means $8.\ \ $ – Bill Dubuque Mar 17 '21 at 21:34