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.
%I A362332 #33 Jun 29 2023 10:59:56 %S A362332 1,2,6,24,120,3,21,168,1512,15120,166320,13860,180180,12870,858,13728, %T A362332 233376,4200768,79814592,1596291840,7,154,3542,4,100,2600,70200, %U A362332 1965600,57002400,1900080,58902480,1884879360,62201018880 %N A362332 For n > 1, if n appears in the sequence then a(n) = lastindex(n), where lastindex(n) is the index of the last appearance of n. Otherwise a(n+1) = a(n)/(n+1) if (n+1)|a(n), otherwise a(n)*(n+1), a(1) = 1 and a(2) = 1*2. %H A362332 Michael De Vlieger, <a href="/A362332/b362332.txt">Table of n, a(n) for n = 1..4306</a> %H A362332 Michael De Vlieger, <a href="/A362332/a362332.png">Plot p(i)^e(i) | a(n) at (x,y) = (n,i)</a> 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. %e A362332 a(2) = 2, as a(1) = 1 and 1 times 2 is 2. %e A362332 a(6) = 3, as a(3) = 6 = n, thus a(6) = 3. %e A362332 a(7) = 21, as a(6) = 3 and 3 times 7 is 21. %t A362332 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 *) %o A362332 (PARI) pos(n, va) = for (k=1, #va, if (va[k] == n, return (k));); %o A362332 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 %o A362332 (Python) %o A362332 from itertools import count, islice %o A362332 def A362332_gen(): # generator of terms %o A362332 a, ndict = 2, {1:1,2:2} %o A362332 yield from [1,2] %o A362332 for n in count(3): %o A362332 yield (a:= ndict[n] if n in ndict else (a*n if a%n else a//n)) %o A362332 ndict[a] = n %o A362332 A362332_list = list(islice(A362332_gen(),30)) # _Chai Wah Wu_, Jun 29 2023 %Y A362332 Cf. A008336, A340612. %K A362332 nonn %O A362332 1,2 %A A362332 _Kelvin Voskuijl_, Apr 16 2023