cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

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.

Original entry on oeis.org

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

Views

Author

Robert G. Wilson v, Oct 24 2017

Keywords

Comments

Conjecture: this sequence is infinite.
First differs from A059459 at a(15).
By definition of a Hamming distance of 1, the first forward absolute difference between a(n-1) and a(n) is a power of two (A000079).
The exponent of two in those differences is 0, 2, 1, 3, 4, 1, 3, 2, 1, 13, 6, 11, 13, 4, 10, 5, 14, 6, 5, 10, 16, 9, 8, 21, 6, 19, 11, 14, 21, 6, 4, 5, 9, 16, 38, 4, 20, 38, 6, 17, 22, 20, 14, 22, 10, 14, 2, 10, 46, 1, 28, 3, 56, 75, 3, 8, 16, 27, 75, 3, 20, 25, 606, 807, 2052, 2177, 886, 759, 796, 5357, 966, 399, etc.
Note that it is not true that for every prime m there is some k such that m+2^k is prime: see comments and links at A094076. Thus it is quite conceivable that the sequence is finite. - Robert Israel, Nov 15 2017

Crossrefs

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]