A373546 a(1) = 1, a(2) = 2; for n > 2, a(n) is the smallest unused positive number that shares a factor with a(n-1) if a(n-1) is even otherwise is coprime to a(n-1) if a(n-1) is odd.
1, 2, 4, 6, 3, 5, 7, 8, 10, 12, 9, 11, 13, 14, 16, 18, 15, 17, 19, 20, 22, 24, 21, 23, 25, 26, 28, 30, 27, 29, 31, 32, 34, 36, 33, 35, 37, 38, 40, 42, 39, 41, 43, 44, 46, 48, 45, 47, 49, 50, 52, 54, 51, 53, 55, 56, 58, 60, 57, 59, 61, 62, 64, 66, 63, 65, 67, 68, 70, 72, 69, 71, 73, 74, 76, 78, 75
Offset: 1
Keywords
Examples
a(9) = 10 as a(8) = 8 is an even number and 10 is the smallest unused positive number to share a factor with 8.
Links
- Michael De Vlieger, Table of n, a(n) for n = 1..10000
- Michael De Vlieger, Labeled scatterplot of a(n) n = 1..72, with red indicating prime, gold indicating odd, and dark blue indicating even terms.
Programs
-
Mathematica
kk = 2; nn = 120; c[_] := False; Array[Set[{a[#], c[#]}, {#, True}] &, kk]; j = a[kk]; u = kk + 1; Do[If[EvenQ[j], If[PrimePowerQ[j], p = FactorInteger[j][[1, 1]]; k = #1 + Boole[#2 > 0] & @@ QuotientRemainder[u, p]; While[c[k p], k++]; k *= p, k = u; While[Or[c[k], CoprimeQ[j, k]], k++]], k = u; While[Or[c[k], ! CoprimeQ[j, k]], k++] ]; Set[{a[n], c[k], j}, {k, True, k}]; If[k == u, While[c[u], u++]], {n, kk + 1, nn}]; Array[a, nn] (* Michael De Vlieger, Jun 11 2024 *)
Comments