cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A366958 Numbers whose difference between the largest and smallest digits is equal to 1.

This page as a plain text file.
%I A366958 #25 Nov 06 2023 11:07:58
%S A366958 10,12,21,23,32,34,43,45,54,56,65,67,76,78,87,89,98,100,101,110,112,
%T A366958 121,122,211,212,221,223,232,233,322,323,332,334,343,344,433,434,443,
%U A366958 445,454,455,544,545,554,556,565,566,655,656,665,667,676,677,766,767,776,778,787,788
%N A366958 Numbers whose difference between the largest and smallest digits is equal to 1.
%C A366958 The number of n-digit terms of this sequence is 17*A000225(n-1).
%t A366958 Select[Range[800],Max[d=IntegerDigits[#]]-Min[d]==1 &]
%o A366958 (PARI) isok(n) = my(d=digits(n)); vecmax(d) - vecmin(d) == 1; \\ _Michel Marcus_, Oct 30 2023
%o A366958 (Python)
%o A366958 def ok(n): return max(d:=list(map(int, str(n))))-min(d) == 1
%o A366958 print([k for k in range(800) if ok(k)]) # _Michael S. Branicky_, Oct 30 2023
%o A366958 (Python) # faster version for large terms
%o A366958 from itertools import count, islice, product
%o A366958 def agen(diff=1): # generator of terms; change diff for A366960-A366966
%o A366958     for digits in count(2):
%o A366958         s = set()
%o A366958         for lo in range(10-diff):
%o A366958             hi = lo + diff
%o A366958             allowed = list(range(lo, hi+1))
%o A366958             for p in product(allowed, repeat=digits):
%o A366958                 if p[0]==0 or lo not in p or hi not in p: continue
%o A366958                 s.add(int("".join(map(str, p))))
%o A366958         yield from sorted(s)
%o A366958 print(list(islice(agen(), 60))) # _Michael S. Branicky_, Oct 30 2023
%Y A366958 Cf. A000225, A037904.
%Y A366958 Cf. A010785 (difference = 0), A366959 (difference = 2), A366960 (difference = 3), A366961 (difference = 4), A366962 (difference = 5), A366963 (difference = 6), A366964 (difference = 7), A366965 (difference = 8), A366966 (difference = 9).
%K A366958 nonn,base,easy
%O A366958 1,1
%A A366958 _Stefano Spezia_, Oct 30 2023