OFFSET
1,1
COMMENTS
This is the lexicographically least (in positions of the flipped bits) such sequence.
It is not known if the sequence is infinite.
"The prime maze - consider the prime numbers in base 2, starting with the smallest prime (10)2. One can move to another prime number by either changing only one digit of the number, or adding a 1 to the front of the number. Can we reach 11 = (1011)2.? 3331? The Mersennes?" (See 'Prime Links + +'.) If we start at 11 and exclude terms 2 and 3 we get terms 11, 43, 41, and so on. This is the opposite parity sequence.
a(130), if it exists, is greater than 2^130000. - Charles R Greathouse IV, Jan 02 2014
a(130) is equal to a(129) + 2^400092. - Giovanni Resta, Jul 19 2017
LINKS
Charles R Greathouse IV, Table of n, a(n) for n = 1..129 (first 104 terms from T. D. Noe)
Chris K. Caldwell, Prime Links + +.
W. Paulsen, The Prime Number Maze, Web Pages.
W. Paulsen, The Prime Number Maze, Fib. Quart., 40 (2002), 272-279.
Carlos Rivera, Problem 25.- William Paulsen's Prime Numbers Maze, The Prime Puzzles and Problems Connection.
MAPLE
A059459search := proc(a, upto_bit, upto_length) local i, n, t; if(nops(a) >= upto_length) then RETURN(a); fi; t := a[nops(a)]; for i from 0 to upto_bit do n := XORnos(t, (2^i)); if(isprime(n) and (not member(n, a))) then print([op(a), n]); RETURN(A059459search([op(a), n], upto_bit, upto_length)); fi; od; RETURN([op(a), `and no more`]); end;
E.g., call as: A059459search([2], 128, 200);
MATHEMATICA
maxBits = 2^11; ClearAll[a]; a[1] = 2; a[n_] := a[n] = If[ PrimeQ[ a[n-1] ], bits = PadLeft[ IntegerDigits[ a[n-1], 2], maxBits]; For[i = 1, i <= maxBits, i++, bits2 = bits; bits2[[-i]] = 1 - bits[[-i]]; If[ i == maxBits, Print[ "maxBits reached" ]; Break[], If[ PrimeQ[an = FromDigits[ bits2, 2]] && FreeQ[ Table[ a[k], {k, 1, n-1}], an], Return[an] ] ] ], 0]; Table[ a[n], {n, 129}] (* Jean-François Alcover, Jan 17 2012 *)
f[lst_List] := Block[{db2 = IntegerDigits[lst[[-1]], 2]}, exp = Length@ db2; While[pp = db2; pp[[exp]] = If[OddQ@db2[[exp]], 0, 1]; pp = FromDigits[pp, 2]; !PrimeQ[pp] || MemberQ[lst, pp], exp--; If[exp == 0, exp++; PrependTo[db2, 0]]]; Append[lst, pp]]; Nest[f, {2}, 128] (* Robert G. Wilson v, Jul 17 2017 *)
PROG
(PARI) step(n)=my(k, t); while(vecsearch(v, t=bitxor(n, 1<<k)) || !ispseudoprime(t=bitxor(n, 1<<k)), k++); v=Set(concat(v, t)); t
u=v=[2]; u=concat(u, step(2)); for(i=3, 129, u=concat(u, step(u[#u])); print(#u" "u[#u])) \\ Charles R Greathouse IV, Jan 02 2014
(Python)
from sympy import isprime
from itertools import islice
def agen():
seen, cand = set(), 2
while True:
an = cand; bit = 1; seen.add(an); yield an
while cand in seen or not isprime(cand):
cand = an-bit if an&bit else an+bit
bit <<= 1
print(list(islice(agen(), 51))) # Michael S. Branicky, Oct 01 2022
CROSSREFS
KEYWORD
nonn,base,nice
AUTHOR
Gregory Allen, Feb 02 2001
EXTENSIONS
More terms and Maple program from Antti Karttunen, Feb 03 2001, who remarks that he was able to extend the sequence to the 104th term 151115727453207491916143 using the bit-flip-limit 128.
STATUS
approved