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.

A112591 a(n) = prime(n) XOR prime(n + 1).

Original entry on oeis.org

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

Views

Author

Sandeep Chellappen (sandeep.chellappen(AT)gmail.com), Dec 18 2005

Keywords

Comments

When represented in binary, this sequence represents the uncommon bits in two consecutive prime numbers.
a(n) = 2 for indices of the lesser twin primes of the form 4k + 1, A071695. - Michel Marcus, Apr 17 2020

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.
		

Crossrefs

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