A161186 In the sequence of nonprime numbers, an element k's position is either prime or nonprime. If k's position is prime, f(k)= the k-th nonprime-positioned element, else f(k) is the k-th prime-positioned element. Iterated application of x-> f(x) gives disjoint sequences generated by the first elements, which form the current sequence.
1, 6, 8, 9, 10, 12, 15, 18, 20, 21, 22, 25, 26, 27, 32, 33, 34, 35, 36, 38, 40, 44, 45, 48, 49, 50, 51, 52, 55, 57, 58, 62, 63, 64, 66, 69, 70, 72, 75, 76, 77, 78, 81, 82, 84, 85, 87, 88, 90, 91, 92, 93, 94, 98, 99, 100, 102, 104, 108, 110, 112, 114, 115, 116, 117, 120
Offset: 1
Examples
The nonprime numbers are: [1, 4, 6, 8, 9, 10, 12, 14, 15, 16, 18, 20]. Those with prime positions are: [4, 6, 9, 12, 18]. Those with nonprime positions are: [1, 8, 10, 14, 15, 16, 20]. So we have {f(1)} = {1,4,14,60,...}, {f(6)} = {6,16,74,...}, {f(8)} ={8,28,56,...}; so the current sequence are the first elements, {1,6,8,...etc}.
Programs
-
PARI
lista(nn) = {my(va = select(x->(! isprime(x)), [1..nn])); my(vap = vector(primepi(#va), k, va[prime(k)])); my(vanp = Vec(setminus(va, vap))); my(vused = vector(#va), ok=1, last=0, list=List(), new, ok2); while(ok, last++; while ((last <= #vused) && vused[last], last++); if (last > #vused, break); new = va[last]; listput(list, new); ok2 = 1; my(list1 = List()); listput(list1, new); while(ok2, pos = setsearch(va, new); if (!pos, ok2=0, vused[pos] = 1; if (isprime(pos), if (new <= #vanp, new = vanp[new], ok2=0), if (new <= #vap, new = vap[new], ok2=0);); listput(list1, new);););); Vec(list);} \\ Michel Marcus, Aug 18 2022
Extensions
More terms from Michel Marcus, Aug 18 2022