Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
A215014
Numbers where any two consecutive decimal digits differ by 1 after arranging the digits in decreasing order.
11
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 21, 23, 32, 34, 43, 45, 54, 56, 65, 67, 76, 78, 87, 89, 98, 102, 120, 123, 132, 201, 210, 213, 231, 234, 243, 312, 321, 324, 342, 345, 354, 423, 432, 435, 453, 456, 465, 534, 543, 546, 564, 567, 576, 645, 654, 657, 675, 678, 687, 756, 765, 768, 786, 789, 798, 867
OFFSET
1,3
COMMENTS
a(4091131) = 9876543210 is the last term.
Numbers n such that A004186(n) is a term of A033075. - Felix Fröhlich, Dec 26 2017
Also 0 together with positive integers having k distinct digits and the difference between the largest and the smallest digit equal to k-1. - David A. Corneth, Dec 26 2017
FORMULA
If zero is excluded, the number of terms with k digits, 1 <= k <= 10, is (11-k)*k! - (k-1)!. - Franklin T. Adams-Watters, Aug 01 2012
MATHEMATICA
lst = {}; Do[If[Times @@ Differences@Sort@IntegerDigits[n] == 1, AppendTo[lst, n]], {n, 0, 675}]; lst (* Arkadiusz Wesolowski, Aug 01 2012 *)
Join[Range[0, 9], Select[Range[1000], Union[Differences[Sort[ IntegerDigits[ #]]]] == {1}&]] (* Harvey P. Dale, Jan 14 2015 *)
PROG
(PARI) is(n)=my(v=vecsort(eval(Vec(Str(n))))); for(i=2, #v, if(v[i]!=1+v[i-1], return(0))); 1
(PARI) is(n) = if(!n, return(1)); my(d = digits(n), v = vecsort(d, , 8)); #d == #v && v[#v] - v[1] == #v - 1
(Python)
# Ely Golden, Dec 26 2017
def consecutive(li):
for i in range(len(li)-1):
if(li[i+1]!=1+li[i]): return False
return True
def sorted_digits(n):
lst=[]
while(n>0):
lst+=[n%10] ; n//=10
lst.sort() ; return lst
j=0
for i in range(1, 10001):
while(not consecutive(sorted_digits(j))): j+=1
print(str(i)+" "+str(j)) ; j+=1
(Python) # alternate for generating full sequence in seconds
from itertools import permutations as perms
frags = ["0123456789"[i:j] for i in range(10) for j in range(i+1, 11)]
afull = sorted(set(int("".join(s)) for f in frags for s in perms(f)))
print(afull[:70]) # Michael S. Branicky, Aug 04 2022
CROSSREFS
Sequence in context: A357142 A376300 A033075 * A292439 A132577 A247167
KEYWORD
nonn,base,fini
AUTHOR
EXTENSIONS
Name edited by Felix Fröhlich, Dec 26 2017
STATUS
approved