%I #12 Nov 27 2022 12:13:06
%S 0,1,2,2,3,3,4,4,3,2,5,4,6,2,5,4,7,6,8,5,7,2,9,8,5,2,9,7,10,10,11,8,
%T 11,2,7,9,12,2,3,10,13,7,14,11,9,2,15,12,7,10,3,13,16,9,11,14,3,2,17,
%U 15,18,2,9,16,13,11,19,17,3,14,20,18,21,2,15,19,11
%N a(n) is the greatest divisor > 1 of n which has already been listed, otherwise a(n) is the smallest number not yet listed; a(1) = 0.
%C When n is prime, a(n) is the prime index (A000720).
%H Samuel Harkness, <a href="/A357839/b357839.txt">Table of n, a(n) for n = 1..10000</a>
%H Samuel Harkness, <a href="/A357839/a357839.jpg">Log-log Scatterplot of the first 3000000 terms</a>
%H Samuel Harkness, <a href="/A357839/a357839_1.jpg">Scatterplot of the first 3000000 terms</a>
%e For n = 6 the set of all divisors of 6 greater than 1 is {2, 3, 6}. Also, the set of all a(n < 6) is {0, 1, 2, 3}. The greatest divisor of 6 (excluding 1) that has been listed is 3, so a(6) = 3.
%t a = 0; A = {a}; Do[s = Drop[Reverse[Divisors[n]], 1]; s = Drop[s, -1]; If[Length[s] >= 1, Do[If[MemberQ[A, Part[s, d]], AppendTo[A, Part[s, d]]; Break[]], {d, 1, Length[s]}], a++; AppendTo[A, a]], {n, 2, 77}] Print[A]
%o (PARI) first(n)=my(v=vector(n),m); forfactored(k=2,n, v[k[1]]=if(vecsum(k[2][,2])==1, m++, my(t); fordiv(k,d, if(d<=m, t=d)); t)); v \\ _Charles R Greathouse IV_, Oct 14 2022
%Y Cf. A008336, A008344, A051352.
%K nonn,easy
%O 1,3
%A _Samuel Harkness_, Oct 14 2022