OFFSET
0,1
COMMENTS
Starting with 109, this sequence has the same terms as A061479 and A061882. - Georg Fischer, May 24 2022
LINKS
Michael S. Branicky, Table of n, a(n) for n = 0..4500
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
CROSSREFS
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