A342265 Lexicographically earliest sequence of distinct nonnegative terms such that both a(n) and the cumulative sum a(1)+a(2)+...+a(n) have digits in nondecreasing order.
0, 1, 2, 3, 5, 4, 7, 6, 8, 9, 11, 12, 44, 13, 14, 16, 22, 45, 15, 18, 23, 55, 24, 88, 33, 77, 34, 78, 111, 333, 17, 19, 79, 29, 89, 25, 99, 199, 112, 444, 26, 28, 56, 35, 188, 113, 119, 556, 114, 999, 122, 1199, 888, 123, 4444, 36, 66, 124, 118, 222, 445, 115, 129, 67, 133, 667, 134, 68, 889, 223
Offset: 1
Examples
Terms a(1) = 0 to a(5) = 5 sum up to 11: those six numbers have digits in nondecreasing order; terms a(1) = 0 to a(6) = 4 sum up to 15: those seven numbers have digits in nondecreasing order; terms a(1) = 0 to a(7) = 7 sum up to 22: those eight numbers have digits in nondecreasing order; etc.
Links
- Michael S. Branicky, Table of n, a(n) for n = 1..173
Crossrefs
Programs
-
Python
def nondec(n): s = str(n); return s == "".join(sorted(s)) def aupton(terms): alst = [0] for n in range(2, terms+1): an, cumsum = 1, sum(alst) while True: while an in alst: an += 1 if nondec(an) and nondec(cumsum + an): alst.append(an); break else: an += 1 return alst print(aupton(100)) # Michael S. Branicky, Mar 07 2021
Comments