OFFSET
1,1
COMMENTS
The number of n-digit terms of this sequence is 27*4^(n-1) - 41*3^(n-1) + 7*2^n.
LINKS
Stefano Spezia, Table of n, a(n) for n = 1..10000
MATHEMATICA
Select[Range[415], Max[d=IntegerDigits[#]]-Min[d]==3 &]
PROG
(Python)
def ok(n): return max(d:=list(map(int, str(n))))-min(d) == 3
print([k for k in range(420) 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 A366960_gen(): # generator of terms
return chain.from_iterable(sorted(int(''.join(str(d) for d in t)) for a in range(7) for c in combinations_with_replacement(range(a, a+4), l) for t in multiset_permutations((a, a+3)+c) if t[0]) for l in count(0))
(PARI) isok(n) = my(d=digits(n)); vecmax(d) - vecmin(d) == 3; \\ Michel Marcus, Nov 05 2023
CROSSREFS
KEYWORD
nonn,base,easy
AUTHOR
Stefano Spezia, Oct 30 2023
STATUS
approved