A366966 Numbers whose difference between the largest and smallest digits is equal to 9.
90, 109, 190, 209, 290, 309, 390, 409, 490, 509, 590, 609, 690, 709, 790, 809, 890, 900, 901, 902, 903, 904, 905, 906, 907, 908, 909, 910, 920, 930, 940, 950, 960, 970, 980, 990, 1009, 1019, 1029, 1039, 1049, 1059, 1069, 1079, 1089, 1090, 1091, 1092, 1093, 1094, 1095
Offset: 1
Crossrefs
Programs
-
Mathematica
Select[Range[1095],Max[d=IntegerDigits[#]]-Min[d]==9 &]
-
PARI
isok(n) = my(d=digits(n)); vecmax(d) - vecmin(d) == 9; \\ Michel Marcus, Nov 05 2023
-
Python
def ok(n): return max(d:=list(map(int, str(n))))-min(d) == 9 print([k for k in range(1100) if ok(k)]) # Michael S. Branicky, Oct 30 2023
-
Python
from itertools import chain, count, islice, combinations_with_replacement from sympy.utilities.iterables import multiset_permutations def A366966_gen(): # generator of terms return chain.from_iterable(sorted(int(''.join(str(d) for d in t)) for c in combinations_with_replacement(range(10),l) for t in multiset_permutations((0,9)+c) if t[0]) for l in count(0)) A366966_list = list(islice(A366966_gen(),30)) # Chai Wah Wu, Nov 10 2023
Comments