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.

A080098 Triangle T(n,k) = n OR k, 0 <= k <= n, bitwise logical OR, read by rows.

Original entry on oeis.org

0, 1, 1, 2, 3, 2, 3, 3, 3, 3, 4, 5, 6, 7, 4, 5, 5, 7, 7, 5, 5, 6, 7, 6, 7, 6, 7, 6, 7, 7, 7, 7, 7, 7, 7, 7, 8, 9, 10, 11, 12, 13, 14, 15, 8, 9, 9, 11, 11, 13, 13, 15, 15, 9, 9, 10, 11, 10, 11, 14, 15, 14, 15, 10, 11, 10, 11, 11, 11, 11, 15, 15, 15, 15, 11, 11, 11, 11, 12, 13, 14, 15, 12, 13, 14, 15, 12, 13, 14, 15, 12
Offset: 0

Views

Author

Reinhard Zumkeller, Jan 28 2003

Keywords

Examples

			Triangle begins:
   0,
   1,  1,
   2,  3,  2,
   3,  3,  3,  3,
   4,  5,  6,  7,  4,
   5,  5,  7,  7,  5,  5,
   6,  7,  6,  7,  6,  7,  6,
   7,  7,  7,  7,  7,  7,  7,  7,
   8,  9, 10, 11, 12, 13, 14, 15,  8,
   9,  9, 11, 11, 13, 13, 15, 15,  9,  9,
  10, 11, 10, 11, 14, 15, 14, 15, 10, 11, 10,
  ...
		

Crossrefs

Cf. A001316 (number of integers k such that T(n, k) = n in n-th row).
Cf. A350093 (row sums), A003986 (array).
Other triangles: A080099 (AND), A051933 (XOR), A265705 (IMPL), A102037 (CNIMPL).

Programs

  • Haskell
    import Data.Bits ((.|.))
    a080098 n k = n .|. k :: Int
    a080098_row n = map (a080098 n) [0..n]
    a080098_tabl = map a080098_row [0..]
    -- Reinhard Zumkeller, Aug 03 2014, Jul 05 2012
    
  • Mathematica
    T[n_, k_] := n ~BitOr~ k;
    Table[T[n, k], {n, 0, 12}, {k, 0, n}] // Flatten (* Jean-François Alcover, Dec 01 2021 *)
  • Python
    def T(n, k): return n | k
    print([T(n, k) for n in range(13) for k in range(n+1)]) # Michael S. Branicky, Dec 01 2021

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)

A350094 a(n) = Sum_{k=0..n} n CNIMPL k where CNIMPL = NOT(n) AND k is the bitwise logical converse non-implication operator (A102037).

Original entry on oeis.org

0, 0, 1, 0, 6, 4, 3, 0, 28, 24, 21, 16, 18, 12, 7, 0, 120, 112, 105, 96, 94, 84, 75, 64, 84, 72, 61, 48, 42, 28, 15, 0, 496, 480, 465, 448, 438, 420, 403, 384, 396, 376, 357, 336, 322, 300, 279, 256, 360, 336, 313, 288, 270, 244, 219, 192, 196, 168, 141, 112
Offset: 0

Views

Author

Kevin Ryde, Dec 14 2021

Keywords

Comments

The effect of NOT(n) AND k is to retain from k only those bits where n has a 0-bit. Conversely n AND k retains from k those bits where n has a 1-bit. Together they are all bits of k so that a(n) + A222423(n) = Sum_{k=0..n} k = n*(n+1)/2.

Crossrefs

Row sums of A102037.
Cf. A001196 (bit doubling).
Other sums: A222423 (AND), A350093 (OR), A224915 (XOR), A265736 (IMPL).

Programs

  • Maple
    with(Bits): cnimp := (n, k) -> And(Not(n), k):
    seq(add(cnimp(n, k), k = 0..n), n = 0..59); # Peter Luschny, Dec 14 2021
  • PARI
    a(n) = (3*fromdigits(binary(n),4) - n^2 - 2*n)/4;

Formula

a(n) = (A001196(n) - n*(n+2))/4.
a(2*n) = 4*a(n) + n.
a(2*n+1) = 4*a(n).
Showing 1-3 of 3 results.