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.

Showing 1-5 of 5 results.

A375235 Records of A112591.

Original entry on oeis.org

1, 6, 12, 28, 58, 126, 252, 506, 1012, 2042, 4082, 8190, 16366, 32742, 65518, 131056, 262114, 524280, 1048554, 2097146, 4194278, 8388594, 16777208, 33554390, 67108858, 134217716, 268435396, 536870852, 1073741814, 2147483614, 4294967284, 8589934580, 17179869158
Offset: 1

Views

Author

Bill McEachen, Aug 06 2024

Keywords

Comments

Sequence closely parallel to A000295.

Examples

			The first term of A112591 = 1 is a record and is a(1). The next A112591 value > 1 is 6 which is a(2).
		

Crossrefs

Cf. A000295, A014210 (primes where records occur), A014234, A112591.

Programs

  • Mathematica
    a[n_] := BitXor @@ NextPrime[2^n, {-1, 1}]; a[1] = 1; Array[a, 33] (* Amiram Eldar, Aug 08 2024 *)
  • PARI
    a(n)= if(n==1,1,bitxor(precprime(2^n), nextprime(2^n) ))

Formula

a(n) = previous_prime(2^n) XOR next_prime(2^n) = A112591(A014234(n)) for n > 1.

Extensions

More terms from Amiram Eldar, Aug 06 2024

A126084 a(n) = XOR of first n primes.

Original entry on oeis.org

0, 2, 1, 4, 3, 8, 5, 20, 7, 16, 13, 18, 55, 30, 53, 26, 47, 20, 41, 106, 45, 100, 43, 120, 33, 64, 37, 66, 41, 68, 53, 74, 201, 64, 203, 94, 201, 84, 247, 80, 253, 78, 251, 68, 133, 64, 135, 84, 139, 104, 141, 100, 139, 122, 129, 384, 135, 394, 133, 400, 137, 402, 183, 388, 179
Offset: 0

Views

Author

Esko Ranta, Mar 02 2007

Keywords

Comments

The values at odd positive indices are even and the values at even positive indices are odd.
Does this sequence contain any zeros for n > 0? Probabilistically, one would expect so; but none in first 10000 terms. - Franklin T. Adams-Watters, Jul 17 2011
None below 1.5 * 10^11: any prime p such that a(pi(p)) = 0 is 43 bits or longer. Heuristic chances that a prime below 2^100 yields 0 are about 45%. Note that an n-bit prime can yield 0 only if a(pi(p)) is odd, where p is the smallest n-bit prime. That is, for n > 1, there are no zeros from pi(2^n) to pi(2^(n+1)) if A007053(n) is even. - Charles R Greathouse IV, Jul 17 2011

Examples

			a(4) = 3 because ((2 XOR 3) XOR 5) XOR 7 = (1 XOR 5) XOR 7 = 4 XOR 7 = 3
[Or, in base 2]
((10 XOR 11) XOR 101) XOR 111 = (1 XOR 101) XOR 111 = 100 XOR 111 = 11
		

Crossrefs

Programs

  • Mathematica
    Module[{nn=70,prs},prs=Prime[Range[nn]];Table[BitXor@@Take[prs,n],{n,0,nn}]] (* Harvey P. Dale, Jun 23 2016 *)
  • PARI
    al(n)=local(m);vector(n,k,m=bitxor(m,prime(k))) /* Produces a vector without a(0) = 0; Franklin T. Adams-Watters, Jul 17 2011 */
    
  • PARI
    v=primes(300); for(i=2,#v,v[i]=bitxor(v[i],v[i-1])); concat(0, v) \\ Charles R Greathouse IV, Aug 26 2014
    
  • PARI
    q=0; forprime(p=2, 313, print1(q, ","); q=bitxor(q, p)) /* Klaus Brockhaus, Mar 06 2007; adapted by Rémy Sigrist, Oct 23 2017 */
    
  • Python
    from operator import xor
    from functools import reduce
    from sympy import primerange, prime
    def A126084(n): return reduce(xor,primerange(2,prime(n)+1)) if n else 0 # Chai Wah Wu, Jul 09 2022

Formula

a(0) = 0; a(n) = a(n-1) XOR prime(n).

Extensions

More terms from Klaus Brockhaus, Mar 06 2007
Edited by N. J. A. Sloane, Oct 22 2017 (merging old entry A193174 with this)
Edited by Rémy Sigrist, Oct 23 2017

A283750 a(n) = n^2 XOR (n + 1)^2.

Original entry on oeis.org

1, 5, 13, 25, 9, 61, 21, 113, 17, 53, 29, 233, 57, 109, 37, 481, 33, 101, 45, 249, 41, 93, 1013, 81, 49, 213, 125, 457, 89, 205, 69, 1985, 65, 197, 77, 473, 73, 253, 85, 945, 209, 117, 477, 169, 121, 4013, 229, 417, 97, 165, 1005, 185, 105, 413, 181, 1937, 241, 405, 189, 905, 153, 397, 133, 8065, 129, 389, 141, 921
Offset: 0

Views

Author

Ilya Gutkovskiy, Mar 15 2017

Keywords

Comments

XOR the binary representations of n^2 and (n + 1)^2.

Crossrefs

Cf. also A379007.

Programs

Formula

a(n) = A000290(n) XOR A000290(n+1).

A334143 a(n) = bitwise NOR of prime(n) and prime(n+1).

Original entry on oeis.org

0, 0, 0, 0, 0, 2, 12, 8, 0, 0, 0, 18, 20, 16, 0, 0, 0, 0, 56, 48, 48, 32, 36, 6, 26, 24, 16, 16, 2, 0, 0, 116, 116, 96, 104, 96, 64, 88, 80, 64, 72, 64, 0, 58, 56, 40, 32, 0, 24, 18, 16, 0, 4, 4, 248, 240, 240, 224, 226, 228, 192, 200, 200, 192, 194, 128, 164
Offset: 1

Views

Author

Christoph Schreier, Apr 15 2020

Keywords

Examples

			a(6) = prime(6) NOR prime(7) = 13 NOR 17 = 2.
		

Crossrefs

Programs

  • Maple
    a:= n-> Bits[Nor](ithprime(n), ithprime(n+1)):
    seq(a(n), n=1..70);  # Alois P. Heinz, Apr 15 2020
  • Mathematica
    A334143[n_]:=With[{b=BitOr[Prime[n],Prime[n+1]]},2^BitLength[b]-b-1];Array[A334143,100] (* Paolo Xausa, Oct 13 2023 *)
  • PARI
    a(n) = my(x=bitor(prime(n), prime(n+1))); bitneg(x, #binary(x)); \\ Michel Marcus, Apr 16 2020
  • Python
    def NORprime(n):
        s = str(bin(primes[n]))[2:]
        t = str(bin(primes[n-1]))[2:]
        k = (len(s) -  len(t))
        t = k*'0' + t
        r = ''
        for i in range(len(s)):
            if s[i] == t[i] and s[i] == '0':
                r += '1'
            else:
                r += '0'
        return int(r,2)
    

Formula

a(n) = A035327(A175329(n)).

A334172 Bitwise XNOR of prime(n) and prime(n + 1).

Original entry on oeis.org

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

Views

Author

Christoph Schreier, Apr 17 2020

Keywords

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

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.
		

Crossrefs

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

Formula

a(n) = A035327(A112591(n)).
Showing 1-5 of 5 results.