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”).

A060982
a(n) = Smallest nontrivial number k > 9 such that |first (leftmost) decimal digit of k - second digit + third digit - fourth digit ...| = n.
27
11, 10, 13, 14, 15, 16, 17, 18, 19, 90, 109, 209, 309, 409, 509, 609, 709, 809, 909, 10909, 20909, 30909, 40909, 50909, 60909, 70909, 80909, 90909, 1090909, 2090909, 3090909, 4090909, 5090909, 6090909, 7090909, 8090909, 9090909, 109090909, 209090909, 309090909
OFFSET
0,1
COMMENTS
Starting with 109, this sequence has the same terms as A061479 and A061882. - Georg Fischer, May 24 2022
LINKS
FORMULA
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
MATHEMATICA
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} ]
PROG
(Python)
def f(m): return abs(sum((-1)**i*int(d) for i, d in enumerate(str(m))))
def a(n):
m = 10
while f(m) != n: m += 1
return m
print([a(n) for n in range(28)]) # Michael S. Branicky, Nov 10 2021
(Python) # faster version based on formula
def a(n):
if n < 10: return [11, 10, 13, 14, 15, 16, 17, 18, 19, 90][n]
q, r = divmod(n, 9)
return int(str(r if r else 9) + "09"*(q if r else q-1))
print([a(n) for n in range(40)]) # Michael S. Branicky, Nov 10 2021
KEYWORD
base,nonn,easy
AUTHOR
Robert G. Wilson v, May 10 2001
EXTENSIONS
a(39) and beyond from Michael S. Branicky, Nov 10 2021
Definition amended by Georg Fischer, May 24 2022
STATUS
approved