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.

A137985 Complementing any single bit in the binary representation of these primes does not produce a prime number.

This page as a plain text file.
%I A137985 #99 Jul 28 2025 14:30:48
%S A137985 127,173,191,223,233,239,251,257,277,337,349,373,431,443,491,509,557,
%T A137985 653,683,701,733,761,787,853,877,1019,1193,1201,1259,1381,1451,1453,
%U A137985 1553,1597,1709,1753,1759,1777,1973,2027,2063,2333,2371,2447,2633,2879,2917,2999
%N A137985 Complementing any single bit in the binary representation of these primes does not produce a prime number.
%C A137985 If 2^m is the highest power of 2 in the binary representation of the prime p, there is no requirement that p+2^(m+1) be composite. Sequence A065092 imposes this extra requirement. The prime 223 is the first number in this sequence that is not in A065092.
%C A137985 Mentioned Feb 25 2008 by _Terence Tao_ in his blog http://terrytao.wordpress.com. Tao proves that there are an infinite number of these primes in every fixed base.
%C A137985 Digitally delicate primes in base 2. - _Marc Morgenegg_, Apr 21 2021
%H A137985 T. D. Noe, <a href="/A137985/b137985.txt">Table of n, a(n) for n = 1..10000</a>
%H A137985 Fred Cohen and J. L. Selfridge, <a href="https://doi.org/10.1090/S0025-5718-1975-0376583-0">Not every number is the sum or difference of two prime powers</a>, Math. Comp. 29 (1975), 79-81.
%H A137985 Warren D. Smith et al., <a href="http://groups.yahoo.com/group/primenumbers/message/24989">Primes such that every bit matters?</a>, Yahoo group "primenumbers", April 2013.
%H A137985 Warren D. Smith and others, <a href="/A137985/a137985.txt">Primes such that every bit matters?</a>, digest of 14 messages in primenumbers Yahoo group, Apr 3 - Apr 9, 2013. [Cached copy]
%H A137985 Terence Tao, <a href="http://arxiv.org/abs/0802.3361">A remark on primality testing and decimal expansions</a>, arXiv:0802.3361 [math.NT], 2008-2010; Journal of the Australian Mathematical Society 91:3 (2011), pp. 405-413.
%H A137985 Eric Weisstein, <a href="https://mathworld.wolfram.com/WeaklyPrime.html">Weakly Prime.</a> From MathWorld - A Wolfram Web Resource.
%H A137985 Wikipedia, <a href="https://en.wikipedia.org/wiki/Delicate_prime">Delicate prime</a>
%e A137985 The numbers produced by complementing each of the 8 bits of 223 are 95, 159, 255, 207, 215, 219, 221 and 222, which are all composite.
%p A137985 q:= p-> isprime(p) and not ormap(i->isprime(Bits[Xor](p, 2^i)), [$0..ilog2(p)]):
%p A137985 select(q, [$2..5000])[];  # _Alois P. Heinz_, Jul 28 2025
%t A137985 t={}; k=1; While[Length[t]<100, k++; p=Prime[k]; d=IntegerDigits[p,2]; n=Length[d]; i=0; While[i<n && (d[[n-i]]==1 && !PrimeQ[p-2^i]) || (d[[n-i]]==0 && !PrimeQ[p+2^i]), i++ ]; If[i==n, AppendTo[t,p]]]; t  (* _T. D. Noe_ *)
%t A137985 isWPbase2[z_] := NestWhile[#*2 &, 2, (# < z && ! PrimeQ@BitXor[z, #] &)] > z; Select[Prime /@ Range[3, PrimePi[10^6]], isWPbase2@# &] (* _Terentyev Oleg_, Jul 17 2011 *)
%t A137985 Select[Prime[Range[500]], NoneTrue[BitXor[#, 2^Range[0, BitLength[#] - 1]], PrimeQ] &] (* _Paolo Xausa_, Apr 23 2025 *)
%o A137985 (PARI)f(p)={pow2=1;v=binary(p);L=#v;
%o A137985 forstep(k=L,1,-1,if(v[k],p-=pow2;if(isprime(p),return(0),p+=pow2),p+=pow2;if(isprime(p),return(0),p-=pow2)); pow2*=2);return(1)}; forprime(p=2,2879,if(f(p), print1(p,", "))) \\ _Washington Bomfim_, Jan 18 2011
%o A137985 (PARI) is_A137985(n)=!for(k=1,n,isprime(bitxor(n,k)) && return;k+=k-1) && isprime(n) \\ Note: A bug in early versions of PARI 2.6 (execute "for(i=0,1,i>3 && error(buggy);i=9)" to check) makes that this is is_A065092 rather than is_A137985 as expected. For these versions, replace the upper limit n with n\2. \\ _M. F. Hasler_, Apr 05 2013
%o A137985 (Python)
%o A137985 from sympy import isprime, primerange
%o A137985 def ok(p): # p assumed prime
%o A137985   return not any(isprime((1<<k)^p) for k in range(p.bit_length()))
%o A137985 def aupto(limit):
%o A137985   alst = []
%o A137985   for p in primerange(2, limit+1):
%o A137985     if ok(p): alst.append(p)
%o A137985   return alst
%o A137985 print(aupto(2917)) # _Michael S. Branicky_, Feb 16 2021
%Y A137985 Cf. A050249 (analogous base 10 sequence), A186995 (weak primes in base n).
%Y A137985 A065092 is a very similar sequence.
%K A137985 nonn,base
%O A137985 1,1
%A A137985 _T. D. Noe_, Feb 26 2008
%E A137985 Definition clarified by _Chai Wah Wu_, Jan 03 2019
%E A137985 Name edited by _Paolo Xausa_, Apr 24 2025