A352950 Lexicographically earliest infinite sequence of distinct nonnegative integers commencing 1,3,5,7 such that any four consecutive terms are pairwise coprime.
1, 3, 5, 7, 2, 9, 11, 13, 4, 15, 17, 19, 8, 21, 23, 25, 16, 27, 29, 31, 10, 33, 37, 41, 14, 39, 43, 47, 20, 49, 51, 53, 22, 35, 57, 59, 26, 55, 61, 63, 32, 65, 67, 69, 28, 71, 73, 45, 34, 77, 79, 75, 38, 83, 89, 81, 40, 91, 97, 87, 44, 85, 101, 93, 46, 95, 103, 99, 52, 107, 109, 105
Offset: 1
Keywords
Examples
3,5,7 are pairwise coprime and 2 is the smallest unused number coprime to all of them, therefore a(5)=2.
Links
- Michael De Vlieger, Log-log scatterplot of a(n), n = 1..2^14, highlighting primes in green, numbers divisible by 6 in gold, other even numbers in red, odd numbers divisible by 3 in blue.
Programs
-
Maple
ina := proc(n) false end: # adapted from code for A103683 a := proc (n) option remember; local k; if n < 5 then k := 2*n-1 else for k from 2 while ina(k) or igcd(k, a(n-1)) <> 1 or igcd(k, a(n-2)) <> 1 or igcd(k, a(n-3)) <> 1 do end do end if; ina(k):= true; k end proc; seq(a(n), n = 1 .. 100);
-
Mathematica
Block[{a, c, k, m, u, nn}, nn = 86; c[] = 0; MapIndexed[Set[{a[First[#2]], c[#1]}, {#1, First[#2]}] &, {1, 3, 5, 7}]; u = 2; Do[k = u; m = LCM @@ Array[a[i - #] &, 3]; While[Nand[c[k] == 0, CoprimeQ[m, k]], k++]; Set[{a[i], c[k]}, {k, i}]; If[a[i] == u, While[c[u] > 0, u++]], {i, 5, nn}]; Array[a, nn] ] (* _Michael De Vlieger, Apr 12 2022 *)
-
Python
from math import gcd from itertools import islice def agen(): # generator of terms aset, b, c, d = {1, 3, 5, 7}, 3, 5, 7 yield from [1, b, c, d] while True: k = 1 while k in aset or any(gcd(t, k) != 1 for t in [b, c, d]): k+= 1 b, c, d = c, d, k aset.add(k) yield k print(list(islice(agen(), 107))) # Michael S. Branicky, Apr 10 2022
Comments