OFFSET
1,1
COMMENTS
The number of n-digit terms of this sequence is 9*10^(n-1) - 17*9^(n-1) + 8^n.
MATHEMATICA
Select[Range[1095], Max[d=IntegerDigits[#]]-Min[d]==9 &]
PROG
(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))
(PARI) isok(n) = my(d=digits(n)); vecmax(d) - vecmin(d) == 9; \\ Michel Marcus, Nov 05 2023
CROSSREFS
KEYWORD
nonn,base,easy
AUTHOR
Stefano Spezia, Oct 30 2023
STATUS
approved