login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

a(n) = Smallest nontrivial number k > 9 such that |first (leftmost) decimal digit of k - second digit + third digit - fourth digit ...| = n.
27

%I #13 May 24 2022 07:57:20

%S 11,10,13,14,15,16,17,18,19,90,109,209,309,409,509,609,709,809,909,

%T 10909,20909,30909,40909,50909,60909,70909,80909,90909,1090909,

%U 2090909,3090909,4090909,5090909,6090909,7090909,8090909,9090909,109090909,209090909,309090909

%N a(n) = Smallest nontrivial number k > 9 such that |first (leftmost) decimal digit of k - second digit + third digit - fourth digit ...| = n.

%C Starting with 109, this sequence has the same terms as A061479 and A061882. - _Georg Fischer_, May 24 2022

%H Michael S. Branicky, <a href="/A060982/b060982.txt">Table of n, a(n) for n = 0..4500</a>

%F For n > 8, if r = 0, a(n) = 90..90, else a(n) = r09..09, where r = n mod 9 and 90 and 09, resp., occur ceiling(n/9) times. - _Michael S. Branicky_, Nov 10 2021

%t m = 2; Do[ While[ a = IntegerDigits[ m ]; l = Length[ a ]; e = o = {}; Do[ o = Append[ o, a[ [ 2k - 1 ] ] ], {k, 1, l/2 + .5} ]; Do[ e = Append[ e, a[ [ 2k ] ] ], {k, 1, l/2} ]; Abs[ Apply[ Plus, o ] - Apply[ Plus, e ] ] != n, m++ ]; Print[ m ], {n, 1, 50} ]

%o (Python)

%o def f(m): return abs(sum((-1)**i*int(d) for i, d in enumerate(str(m))))

%o def a(n):

%o m = 10

%o while f(m) != n: m += 1

%o return m

%o print([a(n) for n in range(28)]) # _Michael S. Branicky_, Nov 10 2021

%o (Python) # faster version based on formula

%o def a(n):

%o if n < 10: return [11, 10, 13, 14, 15, 16, 17, 18, 19, 90][n]

%o q, r = divmod(n, 9)

%o return int(str(r if r else 9) + "09"*(q if r else q-1))

%o print([a(n) for n in range(40)]) # _Michael S. Branicky_, Nov 10 2021

%Y Cf. A008593, A060978-A060980, A060982, A061470-A061479, A061870-A061882.

%K base,nonn,easy

%O 0,1

%A _Robert G. Wilson v_, May 10 2001

%E a(39) and beyond from _Michael S. Branicky_, Nov 10 2021

%E Definition amended by _Georg Fischer_, May 24 2022