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

A224915 a(n) = Sum_{k=0..n} n XOR k where XOR is the bitwise logical exclusive-or operator.

Original entry on oeis.org

0, 1, 5, 6, 22, 23, 27, 28, 92, 93, 97, 98, 114, 115, 119, 120, 376, 377, 381, 382, 398, 399, 403, 404, 468, 469, 473, 474, 490, 491, 495, 496, 1520, 1521, 1525, 1526, 1542, 1543, 1547, 1548, 1612, 1613, 1617, 1618, 1634, 1635, 1639, 1640, 1896, 1897, 1901, 1902, 1918
Offset: 0

Views

Author

Alex Ratushnyak, Apr 19 2013

Keywords

Examples

			a(2) = (0 xor 2) + (1 xor 2) = 2 + 3 = 5.
		

Crossrefs

Cf. A001196 (bit doubling).
Row sums of A051933.
Other sums: A222423 (AND), A350093 (OR), A265736 (IMPL), A350094 (CNIMPL), A004125 (mod).

Programs

  • Maple
    read("transforms"):
    A051933 := proc(n,k)
        XORnos(n,k) ;
    end proc:
    A224915 := proc(n)
        add(A051933(n,k),k=0..n) ;
    end proc: # R. J. Mathar, Apr 26 2013
    # second Maple program:
    with(MmaTranslator[Mma]):
    seq(add(BitXor(n,i),i=0..n),n=0..60); # Ridouane Oudra, Dec 09 2020
  • Mathematica
    Array[Sum[BitXor[#, k], {k, 0, #}] &, 53, 0] (* Michael De Vlieger, Dec 09 2020 *)
  • PARI
    a(n) = sum(k=0, n, bitxor(n, k)); \\ Michel Marcus, Jun 08 2019
    
  • PARI
    a(n) = (3*fromdigits(binary(n),4) - n) >>1; \\ Kevin Ryde, Dec 17 2021
  • Python
    for n in range(59):
        s = 0
        for k in range(n):  s += n ^ k
        print(s, end=',')
    
  • Python
    def A224915(n): return 3*int(bin(n)[2:],4)-n>>1 # Chai Wah Wu, Aug 21 2023
    

Formula

a(n) = Sum_{j=1..n} 4^(v_2(j)), where v_2(j) is the exponent of highest power of 2 dividing j. - Ridouane Oudra, Jun 08 2019
a(n) = n + 3*Sum_{j=1..floor(log_2(n))} 4^(j-1)*floor(n/2^j), for n>=1. - Ridouane Oudra, Dec 09 2020
From Kevin Ryde, Dec 17 2021: (Start)
a(2*n+b) = 4*a(n) + n + b where b = 0 or 1.
a(n) = (A001196(n) - n)/2.
a(n) = A350093(n) - A222423(n), being XOR = OR - AND.
(End)

A102037 Triangle of BitAnd(BitNot(n), k).

Original entry on oeis.org

0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 2, 3, 0, 0, 0, 2, 2, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 0, 0, 0, 2, 2, 4, 4, 6, 6, 0, 0, 0, 1, 0, 1, 4, 5, 4, 5, 0, 1, 0, 0, 0, 0, 0, 4, 4, 4, 4, 0, 0, 0, 0, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0
Offset: 0

Views

Author

Eric W. Weisstein, Dec 25 2004

Keywords

Comments

As a logical operation on two variables this is also called the 'converse nonimplication'. - Peter Luschny, Sep 25 2021

Examples

			Table starts:
[0] 0;
[1] 0, 0;
[2] 0, 1, 0;
[3] 0, 0, 0, 0;
[4] 0, 1, 2, 3, 0;
[5] 0, 0, 2, 2, 0, 0;
[6] 0, 1, 0, 1, 0, 1, 0;
[7] 0, 0, 0, 0, 0, 0, 0, 0;
[8] 0, 1, 2, 3, 4, 5, 6, 7, 0;
[9] 0, 0, 2, 2, 4, 4, 6, 6, 0, 0.
		

Crossrefs

Cf. A350094 (row sums), A268040 (array).
Other triangles: A080099 (AND), A080098 (OR), A051933 (XOR), A265705 (IMPL).

Programs

  • Julia
    using IntegerSequences
    A102037Row(n) = [Bits("CNIMP", n, k) for k in 0:n]
    for n in 0:20 println(A102037Row(n)) end  # Peter Luschny, Sep 25 2021
  • Maple
    with(Bits): cnimp := (n, k) -> And(Not(n), k):
    seq(print(seq(cnimp(n,k), k=0..n)), n = 0..12); # Peter Luschny, Sep 25 2021

A350093 a(n) = Sum_{k=0..n} n OR k where OR is the bitwise logical OR operator (A003986).

Original entry on oeis.org

0, 2, 7, 12, 26, 34, 45, 56, 100, 114, 131, 148, 174, 194, 217, 240, 392, 418, 447, 476, 514, 546, 581, 616, 684, 722, 763, 804, 854, 898, 945, 992, 1552, 1602, 1655, 1708, 1770, 1826, 1885, 1944, 2036, 2098, 2163, 2228, 2302, 2370, 2441, 2512, 2712, 2786, 2863
Offset: 0

Views

Author

Kevin Ryde, Dec 14 2021

Keywords

Comments

The effect of n OR k is to force a 1-bit at all bit positions where n has a 1-bit, which means n*(n+1) in the sum. Bits of k where n has a 0-bit are NOT(n) AND k = n CNIMPL k so that a(n) = A350094(n) + n*(n+1).

Crossrefs

Cf. A003986 (bitwise OR), A001196 (bit doubling).
Row sums of A080098.
Other sums: A222423 (AND), A224915 (XOR), A265736 (IMPL), A350094 (CNIMPL).

Programs

  • PARI
    a(n) = (3*(n^2 + fromdigits(binary(n),4)) + 2*n) >> 2;

Formula

a(n) = ((3*n+2)*n + A001196(n)) / 4.
a(2*n) = 4*a(n) - n.
a(2*n+1) = 4*a(n) + 2*n + 2.
a(n) = A222423(n) + A224915(n), being OR = AND + XOR.
Showing 1-3 of 3 results.