A334172 Bitwise XNOR of prime(n) and prime(n + 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
Offset: 1
Examples
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.
Links
- Rémy Sigrist, Table of n, a(n) for n = 1..10000
- Eric Weisstein's World of Mathematics, XNOR
- Wikipedia, Bitwise operation
Programs
-
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 *)
-
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
-
Python
def XNORprime(n): return ~(primes[n] ^ primes[n+1]) + (1 << primes[n+1].bit_length())
-
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
Comments