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.

A354833 a(1)=1; for n > 1, a(n) = a(n-1) - n unless that result is already in the sequence or would be negative; otherwise, a(n) = a(n-1) * n.

Original entry on oeis.org

1, 2, 6, 24, 19, 13, 91, 83, 74, 64, 53, 41, 28, 14, 210, 194, 177, 159, 140, 120, 99, 77, 54, 30, 5, 130, 103, 75, 46, 16, 496, 464, 431, 397, 362, 326, 289, 251, 212, 172, 131, 89, 3827, 3783, 3738, 3692, 3645, 3597, 3548, 3498, 3447, 3395, 3342, 3288, 3233, 3177
Offset: 1

Views

Author

Kelvin Voskuijl, Jun 07 2022

Keywords

Examples

			a(7) = 91 because from the previous term (13) you cannot subtract 7, because you would get 6, which is already in the sequence, so multiply 13 by 7 to get 91.
		

Crossrefs

Cf. A355457 (Multiplicative steps).

Programs

  • Mathematica
    a[1] = 1; a[n_] := a[n] = Module[{s = Array[a, n - 1], d}, If[(d = a[n - 1] - n) < 0 || MemberQ[s, d], n * a[n - 1], d]]; Array[a, 50] (* Amiram Eldar, Jun 07 2022 *)
  • PARI
    { seen = Map(); v = 1; for (n=1, 56, mapput(seen, v, 0); print1 (v", "); v=if (mapisdefined(seen, w=v-(n+1)) || w<0, v*(n+1), w)) } \\ Rémy Sigrist, Jul 02 2022
    
  • Python
    from itertools import count, islice
    def agen():
        an, seen = 1, {1}
        yield 1
        for n in count(2):
            t = an - n
            an = t if t not in seen and t >= 0 else an*n
            yield an
            seen.add(an)
    print(list(islice(agen(), 56))) # Michael S. Branicky, Jul 02 2022