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.

This page as a plain text file.
%I A294205 #29 May 26 2018 22:49:03
%S A294205 2,3,7,5,13,29,31,23,19,17,8209,8273,10321,2129,2113,3137,3169,19553,
%T A294205 19489,19457,18433,83969,84481,84737,2181889,2181953,2706241,2704193,
%U A294205 2687809,590657,590593,590609,590641,590129,524593,274878431537,274878431521,274879480097,1573153,1573217,1704289,5898593
%N 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.
%C A294205 Conjecture: this sequence is infinite.
%C A294205 First differs from A059459 at a(15).
%C A294205 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).
%C A294205 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.
%C A294205 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
%H A294205 Robert G. Wilson v, <a href="/A294205/b294205.txt">Table of n, a(n) for n = 1..70</a>
%p A294205 A[1]:= 2: S:= {2}:
%p A294205 L:= [1]:
%p A294205 for n from 2 to 50 do
%p A294205   found:= false;
%p A294205   for i from 1 to nops(L) while not found do
%p A294205     cand:= A[n-1] - 2^L[-i];
%p A294205     if not member(cand,S) and isprime(cand) then
%p A294205       found:= true; L:= subsop(-i=NULL,L) fi;
%p A294205   od;
%p A294205   for k from 0 while not found do
%p A294205     if not member(k,L) then
%p A294205       cand:= A[n-1] + 2^k;
%p A294205       if not member(cand,S) and isprime(cand) then
%p A294205         found:= true; L:= sort([op(L),k]);
%p A294205       fi
%p A294205     fi
%p A294205   od;
%p A294205   A[n]:= cand;
%p A294205   S:= S union {cand};
%p A294205 od:
%p A294205 seq(A[i],i=1..50); # _Robert Israel_, Nov 15 2017
%t A294205 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 *)
%t A294205 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]
%Y A294205 Cf. A000040, A000079, A059459, A094076.
%K A294205 nonn,base
%O A294205 1,1
%A A294205 _Robert G. Wilson v_, Oct 24 2017