A294205 a(1) = 2; for n > 1, a(n) is the least prime p not already in the sequence such that the Hamming distance between p and a(n-1) is 1.
2, 3, 7, 5, 13, 29, 31, 23, 19, 17, 8209, 8273, 10321, 2129, 2113, 3137, 3169, 19553, 19489, 19457, 18433, 83969, 84481, 84737, 2181889, 2181953, 2706241, 2704193, 2687809, 590657, 590593, 590609, 590641, 590129, 524593, 274878431537, 274878431521, 274879480097, 1573153, 1573217, 1704289, 5898593
Offset: 1
Links
- Robert G. Wilson v, Table of n, a(n) for n = 1..70
Programs
-
Maple
A[1]:= 2: S:= {2}: L:= [1]: for n from 2 to 50 do found:= false; for i from 1 to nops(L) while not found do cand:= A[n-1] - 2^L[-i]; if not member(cand,S) and isprime(cand) then found:= true; L:= subsop(-i=NULL,L) fi; od; for k from 0 while not found do if not member(k,L) then cand:= A[n-1] + 2^k; if not member(cand,S) and isprime(cand) then found:= true; L:= sort([op(L),k]); fi fi od; A[n]:= cand; S:= S union {cand}; od: seq(A[i],i=1..50); # Robert Israel, Nov 15 2017
-
Mathematica
hammingDistance[a_, b_] := Count[ IntegerDigits[ BitXor[a, b], 2], 1]; f[s_List] := Block[{p = s[[-1]], q = 3}, While[MemberQ[s, q] || hammingDistance[p, q] > 1, q = NextPrime@q]; Append[s, q]]; s = {2}; Nest[f, s, 26] (* or *) f[s_List] := Block[{k = -Floor[RealExponent[s[[-1]], 2]], p = s[[-1]]}, While[q = If[k < 0, p - 2^-k, p + 2^k]; MemberQ[s, q] || !PrimeQ[q] || hammingDistance[p, q] > 1, k++]; Append[s, q]]; s = {2}; Nest[f, s, 67]
Comments