1

The integers $61231239$, $30302$, and $55$ contain sequences of digits that repeat ($123$, $30$, and $5$). In a given base, I want to filter out integers with repeating digit sequences from the set of non-negative integers and find the $n$th integer in the resulting set.

For example, in base $3$, the first $20$ integers would be $$\{0,1,2,10,12,20,21,101,102,120,121,201,202,210,212,1012,1020,1021,1201,1202\}$$

My question is: Is there any known way of calculating the $n$th integer directly—so I could avoid iterating through all integers and checking whether they contain repeating digit sequences?

  • It's tricky to write down the general formula even for the $n$th number that does not include the digit $5$, since it requires a bunch of log's and floor's (I imagine). Perhaps you should look for an efficient algorithm (since you tagged discrete-mathematics, I guess you're coding it?) instead of a closed form. – Gareth Ma Mar 13 '22 at 19:14

0 Answers0