cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

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.

Original entry on oeis.org

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

Views

Author

Scott R. Shannon, Jun 09 2024

Keywords

Comments

The sequence forms a repetitive pattern of three even numbers separated by 2 followed by three odd numbers separated by 2, the first odd number being 3 less than the third even number. One third of all terms are fixed points, and the primes appear in their natural order.
First differences repeat {1, 2, 2, -3, 2, 2}. - Michael De Vlieger, Jun 11 2024

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.
		

Crossrefs

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 *)