|
|
A366959
|
|
Numbers whose difference between the largest and smallest digits is equal to 2.
|
|
10
|
|
|
13, 20, 24, 31, 35, 42, 46, 53, 57, 64, 68, 75, 79, 86, 97, 102, 113, 120, 123, 131, 132, 133, 200, 201, 202, 210, 213, 220, 224, 231, 234, 242, 243, 244, 311, 312, 313, 321, 324, 331, 335, 342, 345, 353, 354, 355, 422, 423, 424, 432, 435, 442, 446, 453, 456, 464, 465, 466
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
1,1
|
|
COMMENTS
|
The number of n-digit terms of this sequence is (46*3^n - 93*2^n + 48)/6.
|
|
LINKS
|
|
|
MAPLE
|
F:= proc(d) local L, i;
L:= select(t -> max(t) = 2 and min(t) = 0, map(convert, [$3^d..2*3^d-1], base, 3));
L:= map(t -> add(t[-i-1]*10^(i-1), i=1..nops(t)-1), L);
L:= map(t -> seq(t+i*(10^d-1)/9, i=0..7), L);
op(sort(select(t -> t >= 10^(d-1), L)));
end proc:
|
|
MATHEMATICA
|
Select[Range[500], Max[d=IntegerDigits[#]]-Min[d]==2 &]
|
|
PROG
|
(Python)
def ok(n): return max(d:=list(map(int, str(n))))-min(d) == 2
(Python)
from itertools import chain, count, islice, combinations_with_replacement
from sympy.utilities.iterables import multiset_permutations
def A366959_gen(): # generator of terms
return chain.from_iterable(sorted(int(''.join(str(d) for d in t)) for a in range(8) for c in combinations_with_replacement(range(a, a+3), l) for t in multiset_permutations((a, a+2)+c) if t[0]) for l in count(0))
(PARI) isok(n) = my(d=digits(n)); vecmax(d) - vecmin(d) == 2; \\ Michel Marcus, Nov 05 2023
|
|
CROSSREFS
|
|
|
KEYWORD
|
nonn,base,easy
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
|