Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).
%I #32 Sep 29 2022 15:06:00
%S 2,1,5,3,9,3,29,27,21,29,5,51,61,59,37,49,57,1,123,113,121,99,117,71,
%T 123,125,115,121,99,113,3,245,253,225,253,245,193,251,245,225,249,245,
%U 129,251,253,235,243,195,249,243,249,225,245,5,505,501,509,485
%N Bitwise XNOR of prime(n) and prime(n + 1).
%C XOR is exclusive OR, meaning that one bit is on and the other bit is off. XNOR is the negation of XOR, meaning that either both bits are on or both bits are off. For example, 4 in binary is 100 and 6 is 110. Then 100 XOR 110 is 010 but 100 XNOR 110 is 101.
%C From Bertrand's postulate it follows that prime(n + 1) requires only one bit more than prime(n) if they're not the same bit width. In most computer implementations, however, the numbers are placed zero-padded into fixed bit widths using two's complement, making it necessary to make adjustments to avoid unintentionally negative numbers. - _Alonso del Arte_, Apr 18 2020
%H Rémy Sigrist, <a href="/A334172/b334172.txt">Table of n, a(n) for n = 1..10000</a>
%H Eric Weisstein's World of Mathematics, <a href="https://mathworld.wolfram.com/XNOR.html">XNOR</a>
%H Wikipedia, <a href="https://en.wikipedia.org/wiki/Bitwise operation">Bitwise operation</a>
%F a(n) = A035327(A112591(n)).
%e The second prime is 3 (11 in binary) and the third prime is 5 (101 in binary). We see that 011 XNOR 101 = 001. Hence a(2) = 1.
%e The fourth prime is 7 (111 in binary). We see that 101 XNOR 111 = 101. Hence a(3) = 5.
%p a:= n-> (p-> Bits[Not](Bits[Xor](p, ithprime(n+1)),
%p bits=1+ilog2(p)))(ithprime(n)):
%p seq(a(n), n=1..70); # _Alois P. Heinz_, Apr 17 2020
%t Table[BitNot[BitXor[Prime[n], Prime[n + 1]]] + 2^Ceiling[Log[2, Prime[n + 1]]], {n, 50}] (* _Alonso del Arte_, Apr 17 2020 *)
%o (Python)
%o def XNORprime(n):
%o return ~(primes[n] ^ primes[n+1]) + (1 << primes[n+1].bit_length())
%o (PARI) neg(p) = bitneg(p, #binary(p));
%o a(n) = my(p=prime(n), q=nextprime(p+1)); bitor(bitand(p, q), bitand(neg(p), neg(q))); \\ _Michel Marcus_, Apr 17 2020
%o (Scala) val prime: LazyList[Int] = 2 #:: LazyList.from(3).filter(i => prime.takeWhile {
%o j => j * j <= i
%o }.forall {
%o k => i % k != 0
%o })
%o (0 to 63).map(n => ~(prime(n) ^ prime(n + 1)) + 2 * Integer.highestOneBit(prime(n + 1))) // _Alonso del Arte_, Apr 18 2020
%Y Cf. A000040, A112591, A175329, A175330, A334143.
%K base,nonn
%O 1,1
%A _Christoph Schreier_, Apr 17 2020