cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A375477 Lexicographically earliest sequence of distinct nonnegative terms arranged in successive chunks whose digitsum = 10, said chunks being "linked" (see the Comments section for an explanation).

Original entry on oeis.org

0, 1, 2, 3, 4, 40, 6, 60, 10, 12, 20, 5, 21, 11, 8, 80, 101, 13, 15, 50, 14, 41, 23, 30, 7, 70, 100, 1001, 16, 102, 22, 24, 42, 31, 17, 10001, 19, 91, 103, 33, 32, 104, 43, 111, 105, 110, 100001, 106, 201, 107, 1000001, 109, 901, 112, 51, 113, 120, 10000001, 114, 121
Offset: 1

Views

Author

Keywords

Comments

The 1st chunk with digitsum = 10 is (0, 1, 2, 3, 4), ending with a "4". The next chunk with digitsum = 10 must start with a "4" (this is the "link") and is thus (40, 6). As the next chunk with digitsum = 10 must start with a "6", we have (60, 10, 12). The next chunk with digitsum = 10 must start with a "2" and we have (20, 5, 21), etc.
No chunk is allowed to end with a zero. Thus, no intermediate chunk digit sum can be 9, and anytime a chunk needs a digitsum of 2 to "complete", the next term must be of the form 10^k + 1 for k >= 1.
Infinite since there are an infinity of terms with digits sums <= 10.
a(5367) has 1001 digits.

Crossrefs

Cf. A375460.

Programs

  • Python
    from itertools import count, islice
    def bgen(ds): # generator of terms with digital sum ds
        def A051885(n): return ((n%9)+1)*10**(n//9)-1 # due to Chai Wah Wu
        def A228915(n): # due to M. F. Hasler
            p = r = 0
            while True:
                d = n % 10
                if d < 9 and r: return (n+1)*10**p + A051885(r-1)
                n //= 10; r += d; p += 1
        k = A051885(ds)
        while True: yield k; k = A228915(k)
    def agen(): # generator of terms
        an, ds_block, seen, link_set, min2 = 0, 0, set(), "123456789", 11
        while True:
            yield an
            seen.add(an)
            if ds_block == 8:
                while min2 in seen: min2 = 10*min2 - 9
                an, ds_an, link_an = min2, 2, "1"
            else:
                cand_ds = list(range(1, 9-ds_block)) + [10-ds_block]
                dsg = [0] + [bgen(i) for i in range(1, 11-ds_block)]
                dsi = [0] + [(next(dsg[i]), i) for i in range(1, 11-ds_block)]
                while True:
                    k, ds_k = min(dsi[j] for j in cand_ds)
                    if k not in seen:
                        sk, dst = str(k), ds_k + ds_block
                        if sk[0] in link_set:
                            if dst < 9 or (dst == 10 and k%10 != 0):
                                an, ds_an, link_an = k, ds_k, sk[-1]
                                break
                    dsi[ds_k] = (next(dsg[ds_k]), ds_k)
            ds_block = ds_block + ds_an
            if ds_block == 10: ds_block, link_set = 0, link_an
            else: link_set = "123456789"
    print(list(islice(agen(), 60)))