OFFSET
1,2
LINKS
Michael De Vlieger, Table of n, a(n) for n = 1..4306
Michael De Vlieger, Plot p(i)^e(i) | a(n) at (x,y) = (n,i) for n = 1..2048, with a color function representing e(i), where black represents e(i) = 1, red e(i) = 2, etc., 3X vertical exaggeration.
EXAMPLE
a(2) = 2, as a(1) = 1 and 1 times 2 is 2.
a(6) = 3, as a(3) = 6 = n, thus a(6) = 3.
a(7) = 21, as a(6) = 3 and 3 times 7 is 21.
MATHEMATICA
nn = 33; c[_] := 0; Array[Set[{a[#], c[#]}, {#, #}] &, 2]; j = 2; Do[If[c[n] > 0, Set[k, c[n]], If[Divisible[j, n], Set[k, j/n], Set[k, j*n]]]; Set[{a[n], c[k], j}, {k, n, k}], {n, 3, nn}]; Array[a, nn] (* Michael De Vlieger, Jun 23 2023 *)
PROG
(PARI) pos(n, va) = for (k=1, #va, if (va[k] == n, return (k)); );
lista(nn) = my(va = vector(nn)); for (n=1, 2, va[n] = n); for (n=3, nn, my(p=pos(n, va)); if (p, va[n] = p, if (va[n-1] % n, va[n] = n*va[n-1], va[n] = va[n-1]/n); ); ); va; \\ Michel Marcus, Jun 23 2023
(Python)
from itertools import count, islice
def A362332_gen(): # generator of terms
a, ndict = 2, {1:1, 2:2}
yield from [1, 2]
for n in count(3):
yield (a:= ndict[n] if n in ndict else (a*n if a%n else a//n))
ndict[a] = n
CROSSREFS
KEYWORD
nonn
AUTHOR
Kelvin Voskuijl, Apr 16 2023
STATUS
approved