login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A334172 Bitwise XNOR of prime(n) and prime(n + 1). 1
2, 1, 5, 3, 9, 3, 29, 27, 21, 29, 5, 51, 61, 59, 37, 49, 57, 1, 123, 113, 121, 99, 117, 71, 123, 125, 115, 121, 99, 113, 3, 245, 253, 225, 253, 245, 193, 251, 245, 225, 249, 245, 129, 251, 253, 235, 243, 195, 249, 243, 249, 225, 245, 5, 505, 501, 509, 485 (list; graph; refs; listen; history; text; internal format)
OFFSET
1,1
COMMENTS
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.
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
LINKS
Eric Weisstein's World of Mathematics, XNOR
FORMULA
a(n) = A035327(A112591(n)).
EXAMPLE
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.
The fourth prime is 7 (111 in binary). We see that 101 XNOR 111 = 101. Hence a(3) = 5.
MAPLE
a:= n-> (p-> Bits[Not](Bits[Xor](p, ithprime(n+1)),
bits=1+ilog2(p)))(ithprime(n)):
seq(a(n), n=1..70); # Alois P. Heinz, Apr 17 2020
MATHEMATICA
Table[BitNot[BitXor[Prime[n], Prime[n + 1]]] + 2^Ceiling[Log[2, Prime[n + 1]]], {n, 50}] (* Alonso del Arte, Apr 17 2020 *)
PROG
(Python)
def XNORprime(n):
return ~(primes[n] ^ primes[n+1]) + (1 << primes[n+1].bit_length())
(PARI) neg(p) = bitneg(p, #binary(p));
a(n) = my(p=prime(n), q=nextprime(p+1)); bitor(bitand(p, q), bitand(neg(p), neg(q))); \\ Michel Marcus, Apr 17 2020
(Scala) val prime: LazyList[Int] = 2 #:: LazyList.from(3).filter(i => prime.takeWhile {
j => j * j <= i
}.forall {
k => i % k != 0
})
(0 to 63).map(n => ~(prime(n) ^ prime(n + 1)) + 2 * Integer.highestOneBit(prime(n + 1))) // Alonso del Arte, Apr 18 2020
CROSSREFS
Sequence in context: A327691 A175330 A333259 * A085261 A179218 A131119
KEYWORD
base,nonn
AUTHOR
Christoph Schreier, Apr 17 2020
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 16 19:48 EDT 2024. Contains 371754 sequences. (Running on oeis4.)