OFFSET
1,2
LINKS
Rémy Sigrist, Table of n, a(n) for n = 1..22279
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
KEYWORD
nonn
AUTHOR
Kelvin Voskuijl, Jun 07 2022
STATUS
approved