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.

User: Christoph Schreier

Christoph Schreier's wiki page.

Christoph Schreier has authored 6 sequences.

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

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

A334122 a(n) is the sum of all primes <= n, mod n.

Original entry on oeis.org

0, 0, 2, 1, 0, 4, 3, 1, 8, 7, 6, 4, 2, 13, 11, 9, 7, 4, 1, 17, 14, 11, 8, 4, 0, 22, 19, 16, 13, 9, 5, 0, 28, 24, 20, 16, 12, 7, 2, 37, 33, 28, 23, 17, 11, 5, 46, 40, 34, 28, 22, 16, 10, 3, 51, 45, 39, 33, 27, 20, 13, 5, 60, 53, 46, 39, 32, 24, 16, 8, 0, 63, 55
Offset: 1

Author

Christoph Schreier, Apr 15 2020

Keywords

Examples

			a(7) = (2+3+5+7) mod 7 = 17 mod 7 = 3.
		

Crossrefs

Programs

  • Maple
    b:= proc(n) b(n):= `if`(n<2, 0, b(n-1)+`if`(isprime(n), n, 0)) end:
    a:= n-> irem(b(n), n):
    seq(a(n), n=1..80);  # Alois P. Heinz, Apr 15 2020
  • Mathematica
    Mod[Accumulate[(# * Boole @ PrimeQ[#]) & /@ (r = Range[100])], r] (* Amiram Eldar, Apr 15 2020 *)
  • PARI
    a(n) = my(np=primepi(n)); vecsum(primes(np)) % n; \\ Michel Marcus, Apr 16 2020
  • Python
    from sympy import primerange
    a = lambda n: sum(primerange(n + 1)) % n # David Radcliffe, May 10 2025
    

Formula

a(n) = A034387(n) mod n.

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

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

A334085 GCD of n and the product of all primes < n.

Original entry on oeis.org

1, 1, 1, 2, 1, 6, 1, 2, 3, 10, 1, 6, 1, 14, 15, 2, 1, 6, 1, 10, 21, 22, 1, 6, 5, 26, 3, 14, 1, 30, 1, 2, 33, 34, 35, 6, 1, 38, 39, 10, 1, 42, 1, 22, 15, 46, 1, 6, 7, 10, 51, 26, 1, 6, 55, 14, 57, 58, 1, 30, 1, 62, 21, 2, 65, 66, 1, 34, 69, 70, 1, 6, 1, 74, 15
Offset: 1

Author

Christoph Schreier, Apr 14 2020

Keywords

Comments

a(n) = 1 iff n is prime or n = 1.

Examples

			For n=8 the product of all primes < 8 = A034386(7) = 210; gcd(8,210) = 2.
		

Crossrefs

Programs

  • Maple
    a:= n-> `if`(isprime(n), 1, mul(i[1], i=ifactors(n)[2])):
    seq(a(n), n=1..80);  # Alois P. Heinz, Apr 17 2020
  • Mathematica
    a[n_] := GCD[n, Times @@ Select[Range[n - 1], PrimeQ]]; Array[a, 60] (* Amiram Eldar, Apr 14 2020 *)
  • PARI
    a(n) = gcd(n, prod(k=1, n-1, if (isprime(k), k, 1))); \\ Michel Marcus, Apr 14 2020
    
  • PARI
    a(n,f=factor(n))=if(f[,2]==[1]~,1,factorback(f[,1])) \\ Charles R Greathouse IV, Apr 14 2020
  • Python
    def is_prime(n):
        if n == 2 or n == 3:
            return True
        if n % 2 == 0 or n < 2:
            return False
        for i in range(3,int(n**0.5)+1,2):
            if n % i == 0:
                return False
        return True
    def A(n):
        if n < 3:
            raise ValueError('n must be > 2')
        else:
            a = 1
            for i in range(n):
                if is_prime(i):
                    a *= i
        return math.gcd(n,a)
    

Formula

a(n) = gcd(n, A034386(n-1)).
a(n) = 1 if n is prime, else a(n) = A007947(n).

A334045 Bitwise NOR of binary representation of n and n-1.

Original entry on oeis.org

0, 0, 0, 0, 2, 0, 0, 0, 6, 4, 4, 0, 2, 0, 0, 0, 14, 12, 12, 8, 10, 8, 8, 0, 6, 4, 4, 0, 2, 0, 0, 0, 30, 28, 28, 24, 26, 24, 24, 16, 22, 20, 20, 16, 18, 16, 16, 0, 14, 12, 12, 8, 10, 8, 8, 0, 6, 4, 4, 0, 2, 0, 0, 0, 62, 60, 60, 56, 58, 56, 56, 48, 54, 52, 52
Offset: 1

Author

Christoph Schreier, Apr 13 2020

Keywords

Comments

All terms are even.
a(1) = 0, a(2) = 0, and a(2^n + 1) = 2^n - 2 for n > 0. Are there any other cases where n - a(n) < 4? - Charles R Greathouse IV, Apr 13 2020
The answer to the above question is no. Write n as n = (2m+1)*k, i.e. k = A006519(n) is the highest power of 2 dividing n. If m = 0, a(n) = 0 and n - a(n) = n. If m > 0, then a(n) = 2v*k, where v is the 1's complement of m. Thus n-a(n) = (2(m-v)+1)*k. Since m in binary has a leading 1, m - v >= 1 and thus n - a(n) >= 3 with n - a(n) = 3 when n > 2, k = 1 and m - v = 1, i.e. m is a power of 2 and n is of the form 2^r + 1. - Chai Wah Wu, Apr 13 2020

Examples

			a(11) = 11 NOR 10 = bin 1011 NOR 1010 = bin 100 = 4.
		

Crossrefs

Cf. A038712 (n XOR n-1), A086799 (n OR n-1), A129760 (n AND n-1).

Programs

  • Maple
    a:= n-> Bits[Nor](n, n-1):
    seq(a(n), n=1..100);  # Alois P. Heinz, Apr 13 2020
  • PARI
    a(n) = my(x=bitor(n-1, n)); bitneg(x, #binary(x)); \\ Michel Marcus, Apr 13 2020
  • Python
    def norbitwise(n):
        a = str(bin(n))[2:]
        b = str(bin(n-1))[2:]
        if len(b) < len(a):
            b = '0' + b
        c = ''
        for i in range(len(a)):
            if a[i] == b[i] and a[i] == '0':
                c += '1'
            else:
                c += '0'
        return int(c,2)
    
  • Python
    def A334045(n):
        m = n|(n-1)
        return 2**(len(bin(m))-2)-1-m # Chai Wah Wu, Apr 13 2020
    

A334042 Write n^2 in binary, interchange 0's and 1's, convert back to decimal.

Original entry on oeis.org

1, 0, 3, 6, 15, 6, 27, 14, 63, 46, 27, 6, 111, 86, 59, 30, 255, 222, 187, 150, 111, 70, 27, 494, 447, 398, 347, 294, 239, 182, 123, 62, 1023, 958, 891, 822, 751, 678, 603, 526, 447, 366, 283, 198, 111, 22, 1979, 1886, 1791, 1694, 1595, 1494, 1391, 1286, 1179
Offset: 0

Author

Christoph Schreier, Apr 13 2020

Keywords

Crossrefs

Programs

  • Maple
    a:= n-> (l-> add((1-l[i])*2^(i-1), i=1..nops(l)))(convert(n, base, 2)):
    seq(a(n), n=0..60);  # Alois P. Heinz, Apr 13 2020
  • Mathematica
    a[n_] := FromDigits[1 - IntegerDigits[n^2, 2], 2]; Array[a, 55, 0] (* Amiram Eldar, Apr 13 2020 *)
  • PARI
    a(n)=if(n, my(s=n^2); bitneg(s,exponent(s)+1), 1) \\ Charles R Greathouse IV, Apr 13 2020
    
  • Python
    def oppsquare(n):
        s = str(bin(n**2))[2:]
        t = ''
        for i in range(len(s)):
            if s[i] == '0':
                t += '1'
            else:
                t += '0'
        return int(t,2)
    
  • Python
    def A334042(n):
        return 2**(len(bin(n**2))-2)-1-n**2 # Chai Wah Wu, Apr 13 2020

Formula

a(n) = A035327(A000290(n)). - Alois P. Heinz, Apr 13 2020