A112591 a(n) = prime(n) XOR prime(n + 1).
1, 6, 2, 12, 6, 28, 2, 4, 10, 2, 58, 12, 2, 4, 26, 14, 6, 126, 4, 14, 6, 28, 10, 56, 4, 2, 12, 6, 28, 14, 252, 10, 2, 30, 2, 10, 62, 4, 10, 30, 6, 10, 126, 4, 2, 20, 12, 60, 6, 12, 6, 30, 10, 506, 6, 10, 2, 26, 12, 2, 62, 22, 4, 14, 4, 118, 26, 10, 6, 60, 6, 8, 26, 14, 4, 250, 8, 28, 8
Offset: 1
Examples
a(2) = 6 ; since prime(2) = 3, which is 11 in binary, prime(3) = 5, which is 101 in binary; and 011 XOR 101 = 110, which is 6 in decimal.
Links
- Harvey P. Dale, Table of n, a(n) for n = 1..1000
Programs
-
Maple
A112591 := proc(n) local ndual,n2dual,nxor,i ; ndual := convert(ithprime(n),base,2) ; n2dual := convert(ithprime(n+1),base,2) ; nxor := [] ; i := 1 ; while i <= nops(ndual) do nxor := [op(nxor), abs(op(i,ndual)-op(i,n2dual)) ] ; i := i+1 ; od ; while i <= nops(n2dual) do nxor := [op(nxor), op(i,n2dual) ] ; i := i+1 ; od ; add( op(i,nxor)*2^(i-1),i=1..nops(nxor)) ; end: for n from 1 to 80 do printf("%d,",A112591(n)) ; od ; # R. J. Mathar, Mar 07 2007 with(Bits):seq(Xor(ithprime(n),ithprime(n+1)),n=1..50) # Gary Detlefs, Aug 03 2013
-
Mathematica
BitXor@@#&/@Partition[Prime[Range[80]], 2, 1] (* Harvey P. Dale, May 04 2018 *)
-
PARI
a(n) = bitxor(prime(n),prime(n+1)); \\ Joerg Arndt, Aug 04 2013
-
Scala
val prime: LazyList[Int] = 2 #:: LazyList.from(3).filter(i => prime.takeWhile { j => j * j <= i }.forall { k => i % k != 0 }) (0 to 127).map(n => prime(n) ^ prime(n + 1)) // Alonso del Arte, Apr 18 2020
Extensions
More terms and better name from Christopher M. Herron (cmh285(AT)psu.edu), Apr 25 2006
Comments