login
TARDIS numbers: the sum of the first and last digits of the decimal expansion is less than the sum of the middle digits.
0

%I #32 Sep 23 2024 08:13:32

%S 120,130,131,140,141,142,150,151,152,153,160,161,162,163,164,170,171,

%T 172,173,174,175,180,181,182,183,184,185,186,190,191,192,193,194,195,

%U 196,197,230,240,241,250,251,252,260,261,262,263,270,271,272,273,274,280,281

%N TARDIS numbers: the sum of the first and last digits of the decimal expansion is less than the sum of the middle digits.

%C They are bigger on the inside than on the outside. The fictional telephone number of the TARDIS is 95475949, a TARDIS number.

%C There are infinitely many (trivially).

%H Shaun Alan Isherwood, <a href="https://math.stackexchange.com/q/4738364/104041">Is there a formula for TARDIS numbers?</a>, Mathematics Stack Exchange.

%H Wikipedia, <a href="https://en.wikipedia.org/wiki/TARDIS">TARDIS</a>

%e 9+9 < 5+4+7+5+9+4, so 95475949 is a TARDIS number.

%t Select[Range[281], Part[IntegerDigits[#],1] + Part[IntegerDigits[#],IntegerLength[#]] < Sum[Part[IntegerDigits[#],i],{i,2,IntegerLength[#]-1}] &] (* _Stefano Spezia_, Sep 12 2024 *)

%o (Python)

%o def ok(n):

%o d = list(map(int, str(n)))

%o return d[0] + d[-1] < sum(d[1:-1])

%o print([k for k in range(282) if ok(k)]) # _Michael S. Branicky_, Sep 12 2024

%o (Python)

%o from itertools import count, islice, combinations_with_replacement

%o from sympy.utilities.iterables import multiset_permutations

%o def A376151_gen(): # generator of terms

%o for l in count(1):

%o c = []

%o for d in combinations_with_replacement('0123456789',l):

%o if (s:=sum(map(int,d)))>1:

%o for a in range(1,min(10,s)):

%o a2 = a*10**(l+1)

%o for b in range(min(10,s-a)):

%o for x in multiset_permutations(d):

%o c.append(a2+10*int(''.join(x))+b)

%o yield from sorted(c)

%o A376151_list = list(islice(A376151_gen(),53)) # _Chai Wah Wu_, Sep 22 2024

%Y Cf. A101317.

%K nonn,base

%O 1,1

%A _Shaun Alan Isherwood_, Sep 12 2024