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.

A383442 a(0) = 0; thereafter a(n) is the least integer (in absolute value) not yet in the sequence such that the absolute difference between a(n-1) and a(n) is a triangular number; in case of a tie, preference is given to the positive value.

Original entry on oeis.org

0, 1, 2, -1, -2, -3, 3, 4, 5, -5, -4, 6, 7, 8, -7, -6, 9, 10, 11, -10, -9, -8, -11, -12, -13, -14, 14, 13, 12, 15, 16, 17, 18, -18, -15, -16, -17, 19, 20, 21, 22, 23, -22, -19, -20, -21, 24, 25, 26, 27, 28, -27, -24, -23, -26, -25, -28, -29, -30, -31, -32, -33, 33, 30, 29, 32, 31, 34, 35, 36, 37, 38, 39, -39, -36, -35, -34, -37, -38, 40
Offset: 0

Views

Author

N. J. A. Sloane, May 03 2025

Keywords

Comments

Heraclitus (circa 500 BCE) observed that no man can step in the same river twice.
The Heraclitus transform H(S) of a sequence S is formed by starting at 0, and moving s steps to the left or right, where s is any element of S, never visiting any number twice, and moving as close to 0 as possible. In case of a tie, move to the positive term.
The present sequence is the Heraclitus transform of the triangular numbers A000217. For the squares, see A377091. Conjecture: both H(A000217) and H(A000290) contain every (positive or negative) integer. In fact it appears that this property holds whenever S is a monotonically strictly increasing sequence starting with 1. It does not hold for H(A000012), which is A001477.

Crossrefs

Programs

  • Mathematica
    A383442list[nmax_] := Module[{s, a, u = 1}, s[_] := False; s[0] = True; NestList[(While[s[u] && s[-u], u++]; a = u; While[s[a] || !IntegerQ[Sqrt[8*Abs[# - a]+1]], a = Boole[a < 0] - a]; s[a] = True; a) &, 0, nmax]];
    A383442list[100] (* Paolo Xausa, May 05 2025 *)
  • Python
    from math import isqrt
    from itertools import count, islice
    def cond(n): return isqrt(m:=8*n+1)**2 == m
    def agen(): # generator of terms
        an, aset, m = 0, {0}, 1
        for n in count(0):
            yield an
            an = next(s for k in count(m) for s in [k, -k] if s not in aset and cond(abs(an-s)))
            aset.add(an)
            while m in aset and -m in aset: m += 1
    print(list(islice(agen(), 80))) # Michael S. Branicky, May 03 2025