A379899 a(1) = 2. For n > 1, a(n) = smallest prime factor of c=a(n-1)+4 that is not in {a(1), ..., a(n-1)}; if all prime factors of c are in {a(1), ..., a(n-1)}, then we try the next value of c, which is c+4; and so on.
2, 3, 7, 11, 5, 13, 17, 29, 37, 41, 53, 19, 23, 31, 43, 47, 59, 67, 71, 79, 83, 103, 107, 127, 131, 139, 151, 163, 167, 179, 61, 73, 89, 97, 101, 109, 113, 137, 149, 157, 173, 181, 193, 197, 229, 233, 241, 257, 269, 277, 281, 293, 313, 317, 337, 349, 353, 373
Offset: 1
Keywords
Examples
a(2) is 3 because the prime factors of c=a(1)+4 (i.e., 6) are 2 and 3, and 2 already appears in the sequence as a(1). a(6) is 13 because the only prime factor of c=a(5)+4 (i.e., 9) is 3 which already appears in the sequence as a(2). The next value of c (i.e., c+4) is 13, which is prime and does not already appear in the sequence.
Links
- Robert C. Lyons, Table of n, a(n) for n = 1..10000
Crossrefs
Programs
-
Maple
b:= proc(n) option remember; `if`(n<1, {}, b(n-1) union {a(n)}) end: a:= proc(n) option remember; local c, p; p:= infinity; for c from a(n-1)+4 by 4 while p=infinity do p:= min(numtheory[factorset](c) minus b(n-1)) od; p end: a(1):=2: seq(a(n), n=1..200); # Alois P. Heinz, Jan 11 2025
-
Mathematica
nn = 120; c[_] := True; j = 2; s = 4; c[2] = False; Reap[Do[m = j + s; While[k = SelectFirst[FactorInteger[m][[All, 1]], c]; ! IntegerQ[k], m += s]; c[k] = False; j = Sow[k], {nn}] ][[-1, 1]] (* Michael De Vlieger, Jan 11 2025 *)
-
Python
from sympy import primefactors seq = [2] seq_set = set(seq) max_seq_len=100 while len(seq) <= max_seq_len: c = seq[-1] done = False while not done: c = c + 4 factors = primefactors(c) for factor in factors: if factor not in seq_set: seq.append(factor) seq_set.add(factor) done = True break print(seq)
Comments