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.

A003986 Table T(n,k) = n OR k read by antidiagonals.

Original entry on oeis.org

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

Views

Author

Keywords

Examples

			The upper left corner of the array starts in row x=0 with columns y>=0 as:
   0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, ...
   1,  1,  3,  3,  5,  5,  7,  7,  9,  9, 11, 11, 13, ...
   2,  3,  2,  3,  6,  7,  6,  7, 10, 11, 10, 11, 14, ...
   3,  3,  3,  3,  7,  7,  7,  7, 11, 11, 11, 11, 15, ...
   4,  5,  6,  7,  4,  5,  6,  7, 12, 13, 14, 15, 12, ...
   5,  5,  7,  7,  5,  5,  7,  7, 13, 13, 15, 15, 13, ...
   6,  7,  6,  7,  6,  7,  6,  7, 14, 15, 14, 15, 14, ...
   7,  7,  7,  7,  7,  7,  7,  7, 15, 15, 15, 15, 15, ...
   8,  9, 10, 11, 12, 13, 14, 15,  8,  9, 10, 11, 12, ...
   9,  9, 11, 11, 13, 13, 15, 15,  9,  9, 11, 11, 13, ...
  10, 11, 10, 11, 14, 15, 14, 15, 10, 11, 10, 11, 14, ...
		

Crossrefs

Cf. A003987 (XOR) and A004198 (AND). Cf. also A075173, A075175.
Antidiagonal sums are in A006583.

Programs

  • C
    #include 
    int main()
    {
    int n, k;
    for (n=0; n<=20; n++){
        for(k=0; k<=n; k++){
            printf("%d, ", (k|(n - k)));
        }
        printf("\n");
    }
    return 0;
    } /* Indranil Ghosh, Apr 01 2017 */
  • Haskell
    import Data.Bits ((.|.))
    a003986 n k = (n - k) .|. k :: Int
    a003986_row n = map (a003986 n) [0..n]
    a003986_tabl = map a003986_row [0..]
    -- Reinhard Zumkeller, Aug 05 2014
    
  • Maple
    read("transforms") ;
    A003986 := proc(x,y) ORnos(x,y) ;end proc:
    for d from 0 to 12 do for x from 0 to d do printf("%d,", A003986(x,d-x)) ; end do: end do: # R. J. Mathar, May 28 2011
  • Mathematica
    Table[BitOr[k, n - k], {n, 0, 20}, {k, 0, n}] //Flatten (* Indranil Ghosh, Apr 01 2017 *)
  • PARI
    tabl(nn) = {for(n=0, nn, for(k=0, n, print1(bitor(k, n - k), ", "); ); print(); ); };
    tabl(20) \\ Indranil Ghosh, Apr 01 2017
    
  • Python
    for n in range(21):
        print([k|(n - k) for k in range(n + 1)])
    # Indranil Ghosh, Apr 01 2017
    

Formula

T(x,y) = T(y,x) = A080098(x,y). - R. J. Mathar, May 28 2011

Extensions

Name edited by Michel Marcus, Jan 17 2023