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.

A320102 Primes where changing any single bit in the binary representation never results in a smaller prime.

This page as a plain text file.
%I A320102 #47 Jan 13 2022 04:22:02
%S A320102 2,5,17,41,73,97,127,137,149,173,191,193,223,233,239,251,257,277,281,
%T A320102 307,331,337,349,373,389,401,431,443,491,509,521,547,557,569,577,599,
%U A320102 617,641,653,683,701,719,733,757,761,787,809,821,839,853,877,881,907,919,977,997,1019,1033,1087,1093,1153
%N A320102 Primes where changing any single bit in the binary representation never results in a smaller prime.
%C A320102 Rooms in Paulsen's prime number maze that are not connected to any room with a lesser room number.
%C A320102 "The prime number maze is a maze of prime numbers where two primes are connected if and only if their base 2 representations differ in just one bit." - William Paulsen (A065123).
%C A320102 If k is prime and the bit 2^m in k is 0 then 2^m+k is not in the sequence.
%C A320102 If k is in the sequence then 2^m+k is not where the bit 2^m in k is 0. - _David A. Corneth_, Oct 09 2018
%H A320102 Michael S. Branicky, <a href="/A320102/b320102.txt">Table of n, a(n) for n = 1..10000</a>
%H A320102 Paul V. McKinney, <a href="/A320102/a320102.txt">Fortran Program</a>.
%e A320102 7 is not in the sequence because there is a way to change only one single bit of its binary representation that results in a prime smaller than 7 {1(1)1,(1)11} {5,3}.
%e A320102 41 is in the sequence because changing any single bit of its binary representation binary representation never results in a smaller prime {10100(1),10(1)001,(1)01001} {40,25,9}.
%t A320102 q[p_] := PrimeQ[p] && AllTrue[2^(-1 + Position[Reverse @ IntegerDigits[p, 2], 1] // Flatten), !PrimeQ[p - #] &]; Select[Range[1000], q] (* _Amiram Eldar_, Jan 13 2022 *)
%o A320102 (PARI) is(n) = if(!isprime(n), return(0)); b = binary(n); for(i=1, #b, if(b[i]==1, if(isprime(n-2^(#b-i)), return(0)))); 1 \\ _David A. Corneth_, Oct 09 2018
%o A320102 (FORTRAN) See "Links" for program.
%o A320102 (Python)
%o A320102 from sympy import isprime
%o A320102 def ok(n):
%o A320102     if not isprime(n): return False
%o A320102     onelocs = (i for i, bi in enumerate(bin(n)[2:][::-1]) if bi == '1')
%o A320102     return not any(isprime(n-2**k) for k in onelocs)
%o A320102 print([k for k in range(1154) if ok(k)]) # _Michael S. Branicky_, Jan 10 2022
%Y A320102 Cf. A019434, A137985, A065092, A065111, A065123.
%K A320102 base,nonn
%O A320102 1,1
%A A320102 _Paul V. McKinney_, Oct 06 2018