OFFSET
1,2
COMMENTS
The terms studied are all concentrated along lines of different gradient; the prime numbers are all distributed on the lines with gradient < 1 while all other numbers are on the lines with gradient > 1, the highest concentration of terms appearing on a line with gradient ~ 1.04. The uppermost of these lines appear to consist entirely of numbers with two or three distinct prime factors. See the attached images. It is conjectured that this behavior is true for all n.
The primes do not appear in their natural order, with 13 appearing before 11 being the first example. The fixes points being 1, 2, 3, 4, 10, 18, 38; it is likely no more exist.
In the first 200000 terms the longest run of consecutive even terms is eight, beginning at a(7681) = 8078, while the longest run of consecutive odd terms is seven, beginning at a(101234) = 105471. It in unknown if these runs can be of arbitrary length. The sequence is conjectured to be a permutation of the positive numbers.
LINKS
Scott R. Shannon, Table of n, a(n) for n = 1..10000
Michael De Vlieger, Log log scatterplot of a(n), n = 1..2^14, showing primes in red, perfect prime powers in gold, squarefree composites in green, and numbers neither squarefree nor prime powers in blue and purple, where the latter additionally represents powerful numbers.
Scott R. Shannon, Image of the first 100000 terms. Numbers with one, two, three, four, or five and more prime factors, counted with multiplicity, are show as red, yellow, green, blue and violet respectively. The white line is a(n) = n.
Scott R. Shannon, Image of the first 100000 terms. As above except here the colors show the number of distinct prime factors.
Scott R. Shannon, Image of the first 100000 terms. The even terms are shown in red, the odd terms in yellow.
EXAMPLE
a(5) = 6 as a(4) = 4 is even and the most recently appearing odd term is a(3) = 3, and 6 is the smallest unused positive number that shares a factor with 3.
a(7) = 8 as a(6) = 9 is odd and the most recently appearing even term is a(5) = 6, and 8 is the smallest unused positive number that shares a factor with 6.
MATHEMATICA
c[_] := False; j = 3; nn = 120; q[_] := 0; m[_] := 1;
Array[Set[{a[#], c[#]}, {#, True}] &, j]; q[0] = 2; q[1] = 3; u = 5;
Do[If[OddQ[j],
If[PrimePowerQ[q[0]], k = m[2];
While[c[2 k], k++]; k *= 2; While[c[2 m[2]], m[2]++],
k = u; While[Or[c[k], CoprimeQ[q[0], k]], k++]],
If[PrimePowerQ[q[1]],
(k = m[#]; While[c[k #], k++]; k *= #;
While[c[# m[#]], m[#]++]) &[FactorInteger[q[1]][[1, 1]]],
k = u; While[Or[c[k], CoprimeQ[q[1], k]], k++]] ]; q[Mod[j, 2]] = j;
Set[{a[n], c[k], j}, {k, True, k}];
If[k == u, While[c[u], u++]], {n, j + 1, nn}];
Array[a, nn] (* Michael De Vlieger, Jun 20 2024 *)
CROSSREFS
KEYWORD
nonn
AUTHOR
Scott R. Shannon, Jun 11 2024
STATUS
approved