A059661 Like A059459, but each term must be greater than the previous ones.
2, 3, 7, 23, 31, 4127, 4159, 20543, 134238271, 134238527, 167792959, 1241534783, 3389018431, 72108495167, 72108503359, 72108765503, 2722258935367507707706996859526254457151, 2722258935367507707708149781030861304127, 13611294676837538538536137218847444070719
Offset: 1
Links
- N. J. A. Sloane, Maple implementations of XORnos and DIFF
Programs
-
Maple
flip_primes_asc_search := 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 (n > t)) then print([op(a), n]); RETURN(flip_primes_asc_search([op(a), n],upto_bit,upto_length)); fi; od; RETURN([op(a),`and no more`]); end; flip_primes_asc_search([2],512,21);
-
Mathematica
uptobit = 512; uptolength = 17; Clear[f]; f[a_] := f[a] = Module[{n, i, t}, If[Length[a] >= uptolength, Return[a]]; t = a[[-1]]; For[i = 0, i <= uptobit, i++, n = BitXor[t, 2^i]; If[PrimeQ[n] && n > t, Return[f[Append[ a, n]]]]]]; A059661 = f[{2}] (* Jean-François Alcover, Mar 07 2016, adapted from Maple *)
-
Python
from sympy import isprime from itertools import islice def agen(): an, bit = 2, 1 while True: yield an while an&bit or not isprime(an+bit): bit <<= 1 an += bit; bit = 1 print(list(islice(agen(), 17))) # Michael S. Branicky, Oct 01 2022
Formula
a(n) = 2 + Sum_{k=1..n-1} 2^A059662(k). - Pontus von Brömssen, Jan 07 2023
Comments