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!)
A033075 Positive numbers all of whose pairs of consecutive decimal digits differ by 1. 24

%I #54 Aug 26 2021 08:54:06

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

%T 101,121,123,210,212,232,234,321,323,343,345,432,434,454,456,543,545,

%U 565,567,654,656,676,678,765,767,787,789,876

%N Positive numbers all of whose pairs of consecutive decimal digits differ by 1.

%C Number of n-digit terms: 9, 17, 32, 61, 116, 222, 424 (= A090994).

%C Also called 10-esthetic numbers (where in general a q-esthetic number has the property that the consecutive digits of its base-q representation differ by 1, see "Esthetic numbers" by J. M. De Koninck and N. Doyon). - _Narad Rampersad_, Aug 03 2018

%H Reinhard Zumkeller, <a href="/A033075/b033075.txt">Table of n, a(n) for n = 1..10000</a>

%H J. M. De Koninck and N. Doyon, <a href="http://www.jeanmariedekoninck.mat.ulaval.ca/fileadmin/jmdk/Documents/Publications/2009_esthetic_numbers.pdf">Esthetic numbers</a>, Annales des Sciences mathématiques du Québec, 33 (2009), 155-164.

%F a(n) >> n^3.53267..., where the exponent is log 10/log k and k is the largest root of x^5 - x^4 - 4x^3 + 3x^2 + 3x - 1. - _Charles R Greathouse IV_, Mar 11 2014

%t Join[Range[9],Select[Range[2000],Union[Abs[Differences[IntegerDigits[#]]]]=={1}&]] (* _Harvey P. Dale_, Dec 28 2011 *)

%o (Haskell)

%o -- import Data.Set (fromList, deleteFindMin, insert)

%o a033075 n = a033075_list !! (n-1)

%o a033075_list = f (fromList [1..9]) where

%o f s | d == 0 = m : f (insert (10*m+1) s')

%o | d == 9 = m : f (insert (10*m+8) s')

%o | otherwise = m : f (insert (10*m+d-1) (insert (10*m+d+1) s'))

%o where (m,s') = deleteFindMin s

%o d = mod m 10

%o -- _Reinhard Zumkeller_, Feb 21 2012

%o (PARI) diff(v)=vector(#v-1,i,v[i+1]-v[i])

%o is(n)=if(n>9, Set(abs(diff(digits(n))))==[1], n>0) \\ _Charles R Greathouse IV_, Mar 11 2014

%o (Python)

%o def ok(n):

%o s = str(n)

%o return all(abs(int(s[i]) - int(s[i+1])) == 1 for i in range(len(s)-1))

%o print(list(filter(ok, range(1, 877)))) # _Michael S. Branicky_, Aug 22 2021

%o (Python) # faster version for initial segment of sequence

%o def gen(d, s=None): # generate remaining d digits, from start digit s

%o if d == 0:

%o yield tuple()

%o return

%o if s == None:

%o yield from [(i, ) + g for i in range(1, 10) for g in gen(d-1, s=i)]

%o else:

%o if s > 0:

%o yield from [(s-1, ) + g for g in gen(d-1, s=s-1)]

%o if s < 9:

%o yield from [(s+1, ) + g for g in gen(d-1, s=s+1)]

%o def agentod(digits):

%o for d in range(1, digits+1):

%o yield from [int("".join(map(str, g))) for g in gen(d, s=None)]

%o print(list(agentod(11))) # _Michael S. Branicky_, Aug 22 2021

%Y Cf. A090994, A048398 (primes), A048411 (squares), A207954 (palindromes).

%K nonn,base,easy

%O 1,2

%A _Clark Kimberling_

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 19 07:35 EDT 2024. Contains 371782 sequences. (Running on oeis4.)