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.

A306470 a(0) = 0; for n > 0, if the number of blanks already in the sequence is greater than or equal to n, n is filled in at the n-th blank counting from the end of the sequence; otherwise n is added to the end of the sequence followed by n blanks.

Original entry on oeis.org

0, 1, 3, 2, 9, 5, 4, 120, 8, 14, 7, 6, 22, 13, 34, 12, 21, 11, 10, 52, 20, 33, 19, 79, 18, 32, 17, 51, 16, 15, 31, 181, 30, 50, 29, 78, 28, 49, 27, 119, 26, 48, 25, 77, 24, 23, 47, 615, 46, 76, 45, 118, 44, 75, 43, 180, 42, 74, 41, 117, 40, 73
Offset: 0

Views

Author

Jan Koornstra, Feb 17 2019

Keywords

Comments

The consecutive number of blanks added to the sequence (1, 2, 4, 6, 10, 15, ...) appear to form the sequence A112088 - 1. The unique values for the length of the sequence (1, 3, 6, 11, 18, 29, 45, 69, 105, ...) then becomes 1 + the partial sums of A112088.

Examples

			For n < 3, n is added to the sequence along with n blanks (denoted by -1): [0, 1, -1, 2, -1, -1]. There are now three blanks in the sequence, hence n = 3 is filled in at the third blank counting from the end of the sequence: [0, 1, 3, 2, -1, -1].
		

Crossrefs

Cf. A112088.

Programs

  • Mathematica
    TakeWhile[Nest[Function[{a, n, b}, If[b >= n, ReplacePart[a, Position[a, -1][[-n]] -> n ], Join[a, Prepend[ConstantArray[-1, n], n]]]] @@ {#, Max@ # + 1, Count[#, -1]} &, {0}, 10^3], # > -1 &] (* Michael De Vlieger, Mar 24 2019 *)
  • Python
    seq = [0]
    for n in range(1, 1387):
      num_blanks = seq.count(-1)
      if num_blanks >= n: seq[[index for index, value in enumerate(seq) if value == -1][num_blanks - n]] = n
      else: seq += [n] + [-1] * n
    print(seq[:100])