A386482 a(1)=1, a(2)=2; thereafter a(n) is either the greatest number k < a(n-1) not already used such that gcd(k, a(n-1)) > 1, or if no such k exists then a(n) is the smallest number k > a(n-1) not already used such that gcd(k, a(n-1)) > 1.
1, 2, 4, 6, 3, 9, 12, 10, 8, 14, 7, 21, 18, 16, 20, 15, 5, 25, 30, 28, 26, 24, 22, 11, 33, 27, 36, 34, 32, 38, 19, 57, 54, 52, 50, 48, 46, 44, 42, 40, 35, 45, 39, 13, 65, 60, 58, 56, 49, 63, 51, 17, 68, 66, 64, 62, 31, 93, 90, 88, 86, 84, 82, 80, 78, 76, 74, 72, 70, 55, 75, 69, 23, 92, 94, 47, 141, 138, 136, 134, 132, 130, 128
Offset: 1
References
- Geoffrey Caveney, Emails to N. J. A. Sloane, Aug 13 2025 - Aug 15 2025.
Links
- Rémy Sigrist, Table of n, a(n) for n = 1..10000
- Rémy Sigrist, PARI program
- Michael De Vlieger, Log log scatterplot of a(n), n = 1..2^20.
- Michael De Vlieger, Log log scatterplot of a(n), n = 1..2^16, showing primes in red, proper prime powers in gold, squarefree composites in green, and numbers that are neither squarefree nor prime powers in blue and purple, where purple represents powerful numbers that are not prime powers.
Crossrefs
Cf. A064413 (EKG), A387072 (inverse), A387073 (record high points), A387074 (indices of record high points), A387075 (first differences), A387076 (primes in order of appearance), A387077 (indices of primes), A387078 (run lengths of consecutive odd and even terms), A387080 (variant that begins with 1,3).
Programs
-
Mathematica
aList[n_] := Module[{an = 2, aset = <|2 -> True|>, m}, Reap[Sow[1]; Sow[an]; Do[m = SelectFirst[Range[an - 1, 2, -1], ! KeyExistsQ[aset, #] && GCD[#, an] > 1 & ]; If[MissingQ[m], m = NestWhile[# + 1 &, an + 1, !(! KeyExistsQ[aset, #] && GCD[#, an] > 1) & ]]; aset[m] = True; an = m; Sow[an], {n - 2}]][[2, 1]]]; aList[83] (* Peter Luschny, Aug 15 2025 *)
-
PARI
\\ See Links section.
-
Python
from math import gcd from itertools import count, islice def A386482_gen(): # generator of terms yield 1 an, aset = 2, {2} while True: yield an m = next((k for k in range(an-1, 1, -1) if k not in aset and gcd(k, an) > 1), False) if not m: m = next(k for k in count(an+1) if k not in aset and gcd(k, an) > 1) an = m aset.add(an) print(list(islice(A386482_gen(), 83))) # Michael S. Branicky, Aug 15 2025
Comments