OFFSET
1,1
COMMENTS
The number of n-digit terms of this sequence is 17*A000225(n-1).
MATHEMATICA
Select[Range[800], Max[d=IntegerDigits[#]]-Min[d]==1 &]
PROG
(PARI) isok(n) = my(d=digits(n)); vecmax(d) - vecmin(d) == 1; \\ Michel Marcus, Oct 30 2023
(Python)
def ok(n): return max(d:=list(map(int, str(n))))-min(d) == 1
print([k for k in range(800) if ok(k)]) # Michael S. Branicky, Oct 30 2023
(Python) # faster version for large terms
from itertools import count, islice, product
for digits in count(2):
s = set()
for lo in range(10-diff):
hi = lo + diff
allowed = list(range(lo, hi+1))
for p in product(allowed, repeat=digits):
if p[0]==0 or lo not in p or hi not in p: continue
s.add(int("".join(map(str, p))))
yield from sorted(s)
print(list(islice(agen(), 60))) # Michael S. Branicky, Oct 30 2023
CROSSREFS
KEYWORD
nonn,base,easy
AUTHOR
Stefano Spezia, Oct 30 2023
STATUS
approved