Is there a formula for TARDIS numbers?

87 Views Asked by At

This is simply a recreational question about some numbers I came up with.

Definition: Let $x\in \Bbb N$ have decimal expansion $x=\overline{a_1a_2\dots a_n}$. Call $x$ a TARDIS number if $$a_1+a_n<a_2+\dots+a_{n-1}.$$

I call them TARDIS numbers because they're bigger on the inside than on the outside. Incidentally, the fictional telephone number of the TARDIS is 95475949, a TARDIS number!

They're new to the OEIS.

I believe the first few are

$$120, 130, 131, 140, 141, 142,\dots$$

The Question:

What is the formula for the $m$th term in the sequence of TARDIS numbers?

Thoughts:

I don't know.

Writing code that computes the TARDIS numbers less than or equal to, say, $10^k-1$, shouldn't be too difficult; here is what I have in mind (for $k=4$):

for r in [1..9] do
   for s in [0..9] do
      for t in [0..9] do
         if t+r<s then
            Print(t+(10*s)+(100*r), "\n");
         fi;
      od;
   od;
od;

My guess is that one can't get anything simpler than the definition.

Please help :)

1

There are 1 best solutions below

3
On

This is not an answer to the question, but just instructions on how to generate the first few examples in Python.

Generating examples in Python

  1. Download & install Wingware 101 for your machine.

  2. Download & install the latest Python.

    • If there are custom options in the installer, make sure you check at least "Add to Path". That allows you to access Python interpreter from command line and for Wing IDE to find it automatically.
    • Custom install location is best set to C:\Python311 for example for Python 3.11.
  3. Open up Wingware, and go to Project > New Project > Defaults I think. Save your project inside a folder named TARDIS_numbers on your Desktop. Call the project TARDIS_numbers as well.

  4. If Projects panel is not displayed, open it with Tools menu > Projects.

  5. Right-click the blank area in the Project panel and select "Create New File". Call it either main.py or TARDIS_numbers.py.

  6. Copy / paste in the following Python code:

from math import log10

N = 10000

def nth_digit(x, n):
    return (x // 10**n) % 10

def num_digits(x):
    return int(log10(x)) + 1

sequence = []    # TARDIS number sequence

for x in range(120, N):
   digits = num_digits(x)
   fst_digit = digit(x, digits - 1)
   lst_digit = digit(x, 0)
   lhs = fst_digit + lst_digit
   rhs = 0

   for d in range(1, digits - 1):   # literally 1...digits - 2 inclusive
      rhs += digit(x, d)

   if lhs < rhs:
      sequence.append(x)

print(sequence)

  1. Debug the formula since I just coded it in the MSE editor and haven't tested it.

  2. Optimize the formula with a smarter strategy (the above is just the naive / brute-force method), if you'd like to.

  3. Ping me in chat if something goes wrong or you'd like some help!