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

A244587 a(n) = n OR 5.

Original entry on oeis.org

5, 5, 7, 7, 5, 5, 7, 7, 13, 13, 15, 15, 13, 13, 15, 15, 21, 21, 23, 23, 21, 21, 23, 23, 29, 29, 31, 31, 29, 29, 31, 31, 37, 37, 39, 39, 37, 37, 39, 39, 45, 45, 47, 47, 45, 45, 47, 47, 53, 53, 55, 55, 53, 53, 55, 55, 61, 61, 63, 63, 61, 61, 63, 63, 69, 69, 71, 71
Offset: 0

Views

Author

Gary Detlefs, Jun 30 2014

Keywords

Crossrefs

Cf. similar sequences of the type n OR k: A109613 (k=1), A174091 (k=2), A244584 (k=3), A244586 (k=4), this sequence (k=5), A244588 (k=6).

Programs

  • Magma
    [BitwiseOr(n, 5): n in [0..80]]; // Bruno Berselli, Jul 01 2014
    
  • Maple
    with(Bits): seq(Or(n,5), n = 0..60);
  • PARI
    a(n) = bitor(n, 5); \\ Michel Marcus, Jan 19 2023
  • Python
    def A244587(n): return n|5 # Chai Wah Wu, Jan 18 2023
    

Formula

a(n) = (n+5) - (n AND 5).
a(n) = (n XOR 5) + (n AND 5).
a(n) = n +((n+1) mod 2)+4*floor(((n+4) mod 8)/4).
a(n) = (2*n + 4*(-1)^floor(n/4) + (-1)^n + 5)/2. - Bruno Berselli, Jul 01 2014
G.f.: (x^6+x^4-3*x^2+5)/((x+1)*(x^4+1)*(x-1)^2). - Alois P. Heinz, Jul 01 2014

Extensions

Some terms corrected by Bruno Berselli, Jul 01 2014

A382865 Bitwise XOR of all integers between n and 2n (endpoints included).

Original entry on oeis.org

0, 3, 5, 4, 8, 15, 13, 8, 16, 27, 21, 28, 24, 23, 29, 16, 32, 51, 37, 52, 40, 63, 45, 56, 48, 43, 53, 44, 56, 39, 61, 32, 64, 99, 69, 100, 72, 111, 77, 104, 80, 123, 85, 124, 88, 119, 93, 112, 96, 83, 101, 84, 104, 95, 109, 88, 112, 75, 117, 76, 120, 71, 125, 64, 128, 195
Offset: 0

Views

Author

Federico Provvedi, May 21 2025

Keywords

Examples

			a(3) = 3 XOR 4 XOR 5 XOR 6 = 4, in binary representation is: ((011 XOR 100) XOR 101) XOR 110 = (111 XOR 101) XOR 110 = 010 XOR 110 = 100 (4 in decimal).
		

Crossrefs

Programs

  • Maple
    a:= proc(n) option remember; uses Bits; `if`(n=0, 0,
          Xor(Xor(Xor(a(n-1), n-1), 2*n-1), 2*n))
        end:
    seq(a(n), n=0..65);  # Alois P. Heinz, May 26 2025
  • Mathematica
    a[n_] = BitXor[BitOr[n-1, 2] - (-1)^n*(n-1), 4*n]/2; Table[a[n],{n,0, 65}]
  • PARI
    a(n) = my(b=n); for (i=n+1, 2*n, b = bitxor(b, i)); b; \\ Michel Marcus, May 25 2025
    
  • Python
    def A382865(n): return [0, n, 1, n-1][n%4] ^ (2*n) # Karl-Heinz Hofmann, May 26 2025

Formula

a(2n) = A047615(n+1), and for every integer k>1: a(n*2^k -1) = 2^k * A065621(n).
a(4n) = 8*n, a(4n+1) = 2*A114389(n+1) + 1, a(4n+2) = 8*n + 5, a(4n+3) = 4*A065621(n+1).
From Karl-Heinz Hofmann, May 27 2025: (Start)
For all n == 0 (mod 4) --> a(n) = A005843(n) = 2*n
For all n == 1 (mod 4) --> a(n) = A048724(n)
For all n == 2 (mod 4) --> a(n) = A005408(n) = 2*n + 1
For all n == 3 (mod 4) --> a(n) = A048724(n) - 1 (End)
a(n) = (1/2) * XOR(A174091(n-1) - A181983(n-1), 4*n). - Federico Provvedi, May 31 2025
Showing 1-2 of 2 results.