A341011 a(n) is the smallest positive number m not yet in the sequence with the property that the sum of the even digits of m and the sum of the odd digits of m differ by n.
112, 1, 2, 3, 4, 5, 6, 7, 8, 9, 19, 119, 39, 139, 59, 159, 79, 179, 99, 199, 488, 399, 688, 599, 888, 799, 1799, 999, 1999, 11999, 3999, 13999, 5999, 15999, 7999, 17999, 9999, 19999, 68888, 39999, 88888, 59999, 159999, 79999, 179999, 99999, 199999, 1199999, 399999, 1399999, 599999, 1599999, 799999, 1799999, 999999
Offset: 0
Examples
a(19) = 199 since 199 is the smallest number such that the sum of even digits (0) and the sum of odd digits (19) differ by n = 19; a(20) = 488 since 488 is the smallest number such that the sum of even digits (20) and the sum of odd digits (0) differ by n = 20; etc.
Links
- Robert G. Wilson v, Table of n, a(n) for n = 0..8983 (terms 1 to 100 from Carole Dubois)
Crossrefs
Programs
-
Mathematica
del[n_] := Abs[Plus @@ Select[(d = IntegerDigits[n]), OddQ] - Plus @@ Select[d, EvenQ]]; m = 54; s = Table[0, {m}]; c = n = 0; While[c < m, n++; i = del[n]; If[i > 0 && i <= m && s[[i]] == 0, c++; s[[i]] = n]]; s (* Amiram Eldar, Feb 02 2021 *) f[n_] := Block[{b, c, d, e, o}, d = 0; c = Floor[n/9]; b = 10^c -1; While[n != (Plus @@ IntegerDigits[d*10^c + b]), If[ OddQ@ d, d += 2, d++]]; o = d*10^c + b; d = 0; c = Floor[n/8]; b = 8(10^c -1)/9; While[n != (Plus @@ IntegerDigits[d*10^c + b]), If[ OddQ@ d, d++, d += 2]]; e = d*10^c + b; Min[o, e]]; f[0] = 112; (* Robert G. Wilson v, Feb 21 2021 *)
Extensions
a(0) added by Robert G. Wilson v, Feb 21 2021
Comments