A354687 a(1) = 1; for n > 1, a(n) is the smallest positive number that has not yet appeared that shares a factor with a(n-1) and the difference | a(n) - a(n-1) | is distinct from all previous differences.
1, 2, 4, 8, 14, 6, 3, 12, 22, 10, 5, 20, 34, 16, 32, 52, 13, 26, 48, 15, 36, 9, 33, 44, 18, 46, 23, 69, 21, 28, 58, 24, 56, 7, 42, 78, 27, 72, 30, 55, 11, 66, 104, 38, 19, 76, 116, 29, 87, 141, 39, 91, 35, 85, 17, 102, 40, 100, 25, 90, 153, 45, 114, 50, 120, 192, 51, 68, 142, 54, 130, 208, 60
Offset: 1
Keywords
Examples
a(4) = 8 as a(3) = 4, and 8 is the smallest unused number that shares a factor with 4 and whose difference from the previous term,| 8 - 4 | = 4, has not appeared. Note 6 shares a factor with 4 but | 6 - 4 | = 2, and a difference of 2 has already occurred between as | a(3) - a(2) |, so 6 cannot be chosen.
Links
- Michael De Vlieger, Table of n, a(n) for n = 1..10000
- Michael De Vlieger, Annotated log log scatterplot of a(n), n = 1..2^14, showing records in red and local minima in blue, highlighting primes in green and fixed points in gold.
- Scott R. Shannon, Image of the first 100000 terms. The green line is y = n.
Programs
-
Mathematica
nn = 120; c[] = d[] = 0; a[1] = c[1] = 1; a[2] = c[2] = j = 2; u = 3; Do[Set[k, u]; While[Nand[c[k] == 0, d[Abs[k - j]] == 0, ! CoprimeQ[j, k]], k++]; Set[{a[i], c[k], d[Abs[k - j]]}, {k, i, i}]; j = k; If[k == u, While[c[u] > 0, u++]], {i, 3, nn}]; Array[a, nn] (* Michael De Vlieger, Jun 04 2022 *)
-
Python
from math import gcd from sympy import isprime, nextprime from itertools import count, islice def agen(): # generator of terms aset, diffset, an, mink = {1, 2}, {1}, 2, 3 yield from [1, 2] for n in count(3): k = mink while k in aset or abs(an-k) in diffset or gcd(an, k) == 1: k += 1 aset.add(k); diffset.add(abs(k-an)); an = k; yield an while mink in aset: mink += 1 print(list(islice(agen(), 73))) # Michael S. Branicky, Jun 04 2022
Comments