login
First location of n in A331025 or 0 if number is absent.
0

%I #18 Sep 23 2020 11:18:42

%S 1,0,2,3,5,7,11,13,4,17,19,6,23,29,10,9,31,14,37,15,22,41,43,21,25,47,

%T 8,33,53,34,59,39,38,61,55,12,67,71,46,51,73,58,79,57,20,83,89,18,121,

%U 85,62,69,97,28,95,87,74,101,103,30,107,109,44,27,115,82

%N First location of n in A331025 or 0 if number is absent.

%C 26 is the smallest number not in this sequence; A331025(21) and A331025(26) both equal 24; the smallest number to occur in A331025 at least twice.

%e a(9) = 4 because A331025(4) = 9 and no earlier term of A331025 is 9.

%t Block[{nn = 66, s}, s = Select[Range[3 nn], And[# != 2, Or[Log2[#] == 3, PrimeQ@ #, PrimeQ[#/2]]] &]; Insert[#, 0, 2][[1 ;; nn]] &@ Values[KeySort@ PositionIndex@ Array[Times @@ Map[If[#[[1]] == 1, 1, # /. {p_, e_} :> s[[PrimePi@ p]]^e] &, FactorInteger[#]] &, Prime@ Length@ s]][[All, 1]]] (* _Michael De Vlieger_, Aug 21 2020 *)

%o (PARI) isp(n) = (isprime(n) && (n%2)) || (n==8) || (!(n%2) && isprime(n/2)); \\ A232803

%o vA331025(nn) = {my(vall = [1..nn]); my(vp = select(x->isp(x), vall)); for (n=2, nn, my(f=factor(n)); for (k=1, #f~, f[k,1] = vp[primepi(f[k,1])]); vall[n] = factorback(f);); vall;}

%o lista(nn) = {my(vall = vA331025(nn)); my(vr = vector(nn)); for (n=1, nn, my(vs = select(x->(x==n), vall, 1)); if (#vs == 0, vr[n] = 0, vr[n] = vs[1]);); my(vz = select(x->(x==0), vr, 1)); if (#vz > 1, vr = vector(vz[2]-1, k, vr[k]);); vr;} \\ _Michel Marcus_, Sep 14 2020

%Y Cf. A232803, A331025.

%K nonn

%O 1,3

%A _J. Lowell_, Jul 21 2020

%E More terms from _Rémy Sigrist_, Jul 21 2020