A373545 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 odd otherwise is coprime to a(n-1) if a(n-1) is even.
1, 2, 3, 6, 5, 10, 7, 14, 9, 12, 11, 22, 13, 26, 15, 18, 17, 34, 19, 38, 21, 24, 23, 46, 25, 20, 27, 30, 29, 58, 31, 62, 33, 36, 35, 28, 37, 74, 39, 42, 41, 82, 43, 86, 45, 40, 47, 94, 49, 56, 51, 48, 53, 106, 55, 44, 57, 54, 59, 118, 61, 122, 63, 60, 67, 134, 65, 50, 69, 66, 71, 142, 73, 146
Offset: 1
Keywords
Examples
a(7) = 7 as a(6) = 10 is an even number and 7 is the smallest unused positive that is coprime to 10.
Links
- Scott R. Shannon, Table of n, a(n) for n = 1..10000
- Michael De Vlieger, Plot f(a(n)) in rows of 210 terms, n = 1..16380, where color function f renders primes in red, perfect prime powers in gold, squarefree composites in greens, and numbers neither squarefree nor prime powers in blue or purple, where purple additionally signifies powerful numbers that are not prime powers. Bright green represents a primorial, yellow green an even squarefree semiprime, olive green an odd squarefree semiprime, and dark green other squarefree composites. Shows pattern of primes a(n) = p followed by even squarefree semiprimes 2*p, generally where n mod A002110(k) is a reduced residue. The lower image plots f(n), only showing primes in their place for comparison.
- 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.
Programs
-
Mathematica
kk = 2; nn = 120; c[_] := False; Array[Set[{a[#], c[#]}, {#, True}] &, kk]; j = a[kk]; u = kk + 1; Do[If[OddQ[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