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-7 of 7 results.

A175329 a(n) = bitwise OR of prime(n) and prime(n+1).

Original entry on oeis.org

3, 7, 7, 15, 15, 29, 19, 23, 31, 31, 63, 45, 43, 47, 63, 63, 63, 127, 71, 79, 79, 95, 91, 121, 101, 103, 111, 111, 125, 127, 255, 139, 139, 159, 151, 159, 191, 167, 175, 191, 183, 191, 255, 197, 199, 215, 223, 255, 231, 237, 239, 255, 251, 507, 263, 271, 271, 287
Offset: 1

Views

Author

Leroy Quet, Apr 07 2010

Keywords

Comments

Read each binary representation of the primes from right to left and then OR respective digits to form the binary equivalent of each term of this sequence.

Crossrefs

Cf. A000040, A175330 (bitwise AND).
Cf. A086799 (bitwise OR of n and n-1).

Programs

  • Maple
    read("transforms") ; A175329 := proc(n) ORnos(ithprime(n),ithprime(n+1)) ; end proc: seq(A175329(n),n=1..60) ; # R. J. Mathar, Apr 15 2010
    # second Maple program:
    a:= n-> Bits[Or](ithprime(n), ithprime(n+1)):
    seq(a(n), n=1..70);  # Alois P. Heinz, Apr 16 2020
  • Mathematica
    A175329[n_]:=BitOr[Prime[n],Prime[n+1]];Array[A175329,100] (* Paolo Xausa, Oct 13 2023 *)
    BitOr@@#&/@Partition[Prime[Range[60]],2,1] (* Harvey P. Dale, Mar 01 2024 *)
  • PARI
    a(n) = bitor(prime(n), prime(n+1)); \\ Michel Marcus, Apr 20 2020

Extensions

More terms from R. J. Mathar, Apr 15 2010

A214415 Numbers n such that prevprime(2^n) AND nextprime(2^n) = 1, where AND is the bitwise AND operator.

Original entry on oeis.org

2, 4, 6, 8, 12, 15, 16, 23, 25, 30, 37, 53, 55, 57, 67, 75, 76, 81, 82, 84, 95, 108, 129, 132, 135, 139, 143, 155, 160, 163, 180, 181, 188, 192, 203, 204, 210, 222, 244, 263, 273, 277, 280, 287, 289, 295, 297, 308, 315, 319, 325, 330, 341, 367, 370, 393, 394, 406
Offset: 0

Views

Author

Alex Ratushnyak, Aug 07 2012

Keywords

Comments

A007053(a(n)) are indices of 1's in A175330. That is, A175330(A007053(a(n)))=1.
Conjecture: the sequence is infinite.

Examples

			4 is in the sequence because (prevprime(2^4) AND nextprime(2^4)) = 13 AND 17 = 1.
		

Crossrefs

Programs

  • Java
    import java.math.BigInteger;
    public class A214415 {
      public static void main (String[] args) {
        BigInteger b1 = BigInteger.valueOf(1);
        BigInteger b2 = BigInteger.valueOf(2);
        for (int n=2; ; n++) {
          BigInteger pwr = b1.shiftLeft(n);
          BigInteger pm  = pwr.subtract(b1);
          BigInteger pp  = pwr.add(b1);
          while (true) {
            if (pm.isProbablePrime(2)) {
                if (pm.isProbablePrime(80)) break;
            }
            pm  = pm.subtract(b2);
          }
          while (true) {
            if (pp.isProbablePrime(2)) {
                if (pp.isProbablePrime(80)) break;
            }
            pp  = pp.add(b2);
          }
          if (pm.and(pp).equals(b1)) {
            System.out.printf("%d, ",n);
          }
        }
      }
    }
    
  • Mathematica
    ba1Q[n_]:=Module[{c=2^n},BitAnd[NextPrime[c],NextPrime[c,-1]]==1]; Select[ Range[ 450],ba1Q] (* Harvey P. Dale, Dec 25 2012 *)
  • PARI
    { for (n=2,1000,  N = 2^n;
        p1 = precprime(N-1);
        p2 = nextprime(N+1);
        ba = bitand(p1, p2);
        if ( bitand( ba, ba-1 ) == 0, print1(n,", "));
    ); }
    /* Joerg Arndt, Aug 16 2012 */
    
  • Python
    from itertools import islice
    from sympy import prevprime, nextprime
    def A214415_gen(): # generator of terms
        n, m = 2, 4
        while True:
            if prevprime(m)&nextprime(m) == 1:
                yield n
            n += 1
            m *= 2
    A214415_list = list(islice(A214415_gen(),20)) # Chai Wah Wu, Oct 16 2023

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)).

A328266 a(n) is the least k > 0 such that prime(n) AND prime(n+k) <= 1 (where prime(n) denotes the n-th prime number and AND denotes the bitwise AND operator).

Original entry on oeis.org

2, 1, 2, 3, 2, 1, 5, 4, 4, 9, 14, 7, 6, 21, 29, 3, 27, 1, 14, 13, 11, 33, 10, 8, 7, 6, 6, 7, 3, 2, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 43, 42, 44, 48, 39, 41, 45, 36, 35, 34, 41, 40, 49, 30, 47, 31, 27, 26, 43
Offset: 1

Views

Author

Rémy Sigrist, Oct 16 2019

Keywords

Comments

The sequence is well defined: for any n > 0, let x be such that prime(n) < 2^x; as 1 and 2^x are coprime, by Dirichlet's theorem on arithmetic progressions, there is a prime number q of the form q = 1 + k * 2^x, and prime(n) AND q <= 1, QED.
a(n) >= A000720(A062383(A000040(n)))+1-n. - Robert Israel, Oct 17 2019

Examples

			For n = 18:
- prime(18) = 61,
- prime(19) = 67,
- 61 AND 67 = 1,
- so a(18) = 1.
		

Crossrefs

Programs

  • Maple
    f:= proc(n) local L,M,R,j,v,i,x;
      L:= convert(ithprime(n),base,2);
      v:= 2^nops(L);
      M:= select(t -> L[t]=0, [$2..nops(L)]);
      for i from 1 do
        for j from 0 to 2^nops(M)-1  do
          R:= convert(j,base,2);
          x:= 1 + add(2^(M[i]-1), i=select(k -> R[k]=1, [$1..nops(R)]))+i*v;
          if isprime(x) then return numtheory:-pi(x)-n fi
      od od;
    end proc:
    map(f, [$1..100]); # Robert Israel, Oct 17 2019
  • Mathematica
    A328266[n_]:=Module[{q=n,p=Prime[n]},While[BitAnd[p,Prime[++q]]>1];q-n];Array[A328266,100] (* Paolo Xausa, Oct 13 2023 *)
  • PARI
    { forprime (p=2, prime(73), k=0; forprime (q=p+1, oo, k++; if (bitand(p, q)<=1, print1 (k ", "); break))) }

Formula

a(n) = 1 iff A175330(n) = 1.

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)).

A366550 Numbers k such that bitwise AND of prime(k) and prime(k+1) = 1.

Original entry on oeis.org

2, 6, 18, 54, 564, 3512, 6542, 564163, 2063689, 54400028, 5586502348, 252252704148404, 971269945245201, 3745011184713964
Offset: 1

Views

Author

Paolo Xausa, Oct 13 2023

Keywords

Comments

Suggested by a comment by Alex Ratushnyak in A175330.

Examples

			18 is a term since prime(18) AND prime(19) = 1,
  prime(18) = 61 = binary 0111101
  prime(19) = 67 = binary 1000011
  bitwise AND    =        0000001
		

Crossrefs

Positions of ones in A175330.

Programs

  • Mathematica
    A366550list[upto_]:=PrimePi[Select[2^Range[upto],BitAnd[NextPrime[#],NextPrime[#,-1]]==1&]];
    A366550list[37] (* Uses formula, considering values in A214415 up to 37 *)
  • PARI
    isok(k) = bitand(prime(k), prime(k+1)) == 1; \\ Michel Marcus, Oct 14 2023

Formula

a(n) = A007053(A214415(n-1)).

A334150 Primes p such that p AND q = 1, where q is the next prime after p and AND is the bitwise operation.

Original entry on oeis.org

3, 13, 61, 251, 4093, 32749, 65521, 8388593, 33554393, 1073741789, 137438953447, 9007199254740881, 36028797018963913, 144115188075855859, 147573952589676412909, 37778931862957161709471, 75557863725914323419121, 2417851639229258349412301, 4835703278458516698824647
Offset: 1

Views

Author

Michel Marcus, Apr 16 2020

Keywords

Crossrefs

Cf. A175330.
Subsequence of A014234 (largest prime <= 2^n).
Cf. A214415 (exponents of corresponding powers of 2).

Programs

  • Mathematica
    s = {}; p = 2; Do[q = NextPrime[p]; If[BitAnd[p, q] == 1, AppendTo[s, p]]; p = q, {10^5}]; s (* Amiram Eldar, Apr 16 2020 *)
    Select[ NextPrime[ 2^Range[82], -1], BitAnd[#, NextPrime@ #] == 1 &] (* Giovanni Resta, Apr 16 2020 *)
  • PARI
    isok(p) = isprime(p) && (bitand(p, nextprime(p+1)) == 1);

Extensions

a(9)-a(10) from Amiram Eldar, Apr 16 2020
a(11)-a(19) from Giovanni Resta, Apr 16 2020
Showing 1-7 of 7 results.