login
A379165
a(1) = 1, a(2) = 2; for n > 2, a(n) is the smallest unused positive number that is either coprime to both a(n-1) and a(n-2) or shares a factor with both a(n-1) and a(n-2).
2
1, 2, 3, 5, 4, 7, 9, 8, 6, 10, 11, 13, 12, 17, 19, 14, 15, 18, 20, 16, 21, 23, 22, 25, 27, 26, 24, 28, 29, 31, 30, 37, 41, 32, 33, 35, 34, 39, 36, 42, 38, 40, 43, 47, 44, 45, 48, 49, 53, 46, 51, 54, 55, 50, 57, 59, 52, 61, 63, 58, 56, 60, 62, 64, 65, 67, 66, 71, 73, 68, 69, 72, 75, 70, 78, 74, 76, 77, 79, 80, 81, 83, 82, 85, 87, 86, 84, 88, 89, 91
OFFSET
1,2
COMMENTS
For the terms studied the primes appear in their natural order. The fixed points being 3, 8, 10, 11, 18, 21, 26, 28, 29, 43, 51, 64... . After 10 million terms 3211449 of them, approximately 32.1%, share a factor with both previous terms - it is unknown what this ratio is as n -> infinity. The sequence is almost certainly a permutation of the positive numbers.
LINKS
EXAMPLE
a(4) = 5 as 5 is coprime to both a(3) = 3 and a(2) = 2, and 5 has not previously appeared.
a(9) = 6 as 6 shares a factor with both a(8) = 8 and a(7) = 9, and 6 has not previously appeared.
MATHEMATICA
nn = 120; c[_] := False; Do[Set[{a[n], c[k]}, {n, True}], {n, 2}];
i = a[1]; j = a[2]; u = 3;
Do[k = u;
While[Or[c[k], Nor[And[#1, #2], Nor[#1, #2]]] &[
CoprimeQ[k, i], CoprimeQ[k, j]], k++];
Set[{a[n], c[k], i, j}, {k, True, j, k}];
If[k == u, While[c[u], u++]], {n, 3, nn}];
Array[a, nn] (* Michael De Vlieger, Dec 17 2024 *)
CROSSREFS
KEYWORD
nonn
AUTHOR
Scott R. Shannon, Dec 17 2024
STATUS
approved