%I #24 Jan 09 2023 01:45:00
%S 2,3,7,23,31,4127,4159,20543,134238271,134238527,167792959,1241534783,
%T 3389018431,72108495167,72108503359,72108765503,
%U 2722258935367507707706996859526254457151,2722258935367507707708149781030861304127,13611294676837538538536137218847444070719
%N Like A059459, but each term must be greater than the previous ones.
%H N. J. A. Sloane, <a href="/transforms.txt">Maple implementations of XORnos and DIFF</a>
%F a(n) = 2 + Sum_{k=1..n-1} 2^A059662(k). - _Pontus von Brömssen_, Jan 07 2023
%p 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;
%p flip_primes_asc_search([2],512,21);
%t 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 *)
%o (Python)
%o from sympy import isprime
%o from itertools import islice
%o def agen():
%o an, bit = 2, 1
%o while True:
%o yield an
%o while an&bit or not isprime(an+bit): bit <<= 1
%o an += bit; bit = 1
%o print(list(islice(agen(), 17))) # _Michael S. Branicky_, Oct 01 2022
%Y Cf. A033875, A059459, A059662.
%K nonn,base
%O 1,1
%A _Antti Karttunen_, Feb 03 2001
|