login
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.
3
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,2
LINKS
EXAMPLE
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.
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 *)
PROG
(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
CROSSREFS
Cf. A355457 (Multiplicative steps).
Sequence in context: A263692 A363962 A319544 * A124900 A068819 A060068
KEYWORD
nonn
AUTHOR
Kelvin Voskuijl, Jun 07 2022
STATUS
approved