login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A215014 Numbers where any two consecutive decimal digits differ by 1 after arranging the digits in decreasing order. 11

%I #44 Aug 04 2022 15:04:11

%S 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,

%T 98,102,120,123,132,201,210,213,231,234,243,312,321,324,342,345,354,

%U 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

%N Numbers where any two consecutive decimal digits differ by 1 after arranging the digits in decreasing order.

%C a(4091131) = 9876543210 is the last term.

%C Numbers n such that A004186(n) is a term of A033075. - _Felix Fröhlich_, Dec 26 2017

%C 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

%H Ely Golden, <a href="/A215014/b215014.txt">Table of n, a(n) for n = 1..10000</a>

%F 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

%t lst = {}; Do[If[Times @@ Differences@Sort@IntegerDigits[n] == 1, AppendTo[lst, n]], {n, 0, 675}]; lst (* _Arkadiusz Wesolowski_, Aug 01 2012 *)

%t Join[Range[0,9],Select[Range[1000],Union[Differences[Sort[ IntegerDigits[ #]]]] == {1}&]] (* _Harvey P. Dale_, Jan 14 2015 *)

%o (PARI) is(n)=my(v=vecsort(eval(Vec(Str(n)))));for(i=2,#v,if(v[i]!=1+v[i-1],return(0)));1

%o (PARI) is(n) = if(!n, return(1)); my(d = digits(n), v = vecsort(d,,8)); #d == #v && v[#v] - v[1] == #v - 1

%o (Python)

%o # _Ely Golden_, Dec 26 2017

%o def consecutive(li):

%o for i in range(len(li)-1):

%o if(li[i+1]!=1+li[i]): return False

%o return True

%o def sorted_digits(n):

%o lst=[]

%o while(n>0):

%o lst+=[n%10] ; n//=10

%o lst.sort() ; return lst

%o j=0

%o for i in range(1,10001):

%o while(not consecutive(sorted_digits(j))): j+=1

%o print(str(i)+" "+str(j)) ; j+=1

%o (Python) # alternate for generating full sequence in seconds

%o from itertools import permutations as perms

%o frags = ["0123456789"[i:j] for i in range(10) for j in range(i+1, 11)]

%o afull = sorted(set(int("".join(s)) for f in frags for s in perms(f)))

%o print(afull[:70]) # _Michael S. Branicky_, Aug 04 2022

%Y Cf. A004186, A033075.

%K nonn,base,fini

%O 1,3

%A _Tanya Khovanova_ and _Charles R Greathouse IV_, Jul 31 2012

%E Name edited by _Felix Fröhlich_, Dec 26 2017

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 18 22:18 EDT 2024. Contains 371782 sequences. (Running on oeis4.)