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.

A279645 a(n) = not (n XOR (n shift 1)).

Original entry on oeis.org

0, 0, 0, 1, 1, 0, 2, 3, 3, 2, 0, 1, 5, 4, 6, 7, 7, 6, 4, 5, 1, 0, 2, 3, 11, 10, 8, 9, 13, 12, 14, 15, 15, 14, 12, 13, 9, 8, 10, 11, 3, 2, 0, 1, 5, 4, 6, 7, 23, 22, 20, 21, 17, 16, 18, 19, 27, 26, 24, 25, 29, 28, 30, 31, 31, 30, 28, 29, 25, 24, 26, 27, 19, 18, 16
Offset: 0

Views

Author

Paolo P. Lava, Dec 16 2016

Keywords

Comments

In other words, a(n) = the binary complement of (n XOR (n shift 1)). - N. J. A. Sloane, Mar 14 2024
Values of n for which a(n) = 0 are given by A000975(k).
Values of n for which a(n) = 1 are given by A097072(k) (for k>1).

Examples

			5044 converted to base 2 is 1001110110100.
Then consider each pair of adjacent bits starting from MSD: if they are equal, 00 or 11, set 1 otherwise 0:
  (1+0) -> 0
  (0+0) -> 1
  (0+1) -> 0
  (1+1) -> 1
  (1+1) -> 1
  (1+0) -> 0
  (0+1) -> 0
  (1+1) -> 1
  (1+0) -> 0
  (0+1) -> 0
  (1+0) -> 0
  (0+0) -> 1
We get 10110010001, so a(5044) = 1425.
		

Crossrefs

Programs

  • Maple
    P:=proc(n) local a,b,k; a:=0; b:=convert(n,base,2);
    for k to nops(b)-1 do a:=a+((((b[k]+b[k+1]) mod 2)+1) mod 2)*2^(k-1); od; RETURN(a); end;
    [seq(P(i),i=0..100)];
    # alternative ( R. J. Mathar, Jun 22 2020)
    A279645 := proc(n)
        local dgs,L ;
        dgs := convert(n,base,2) ;
        L := [] ;
        for i from 2 to nops(dgs) do
            if op(i,dgs) = op(i-1,dgs) then
                L := [op(L),1] ;
            else
                L := [op(L),0] ;
            fi ;
        end do:
        add( op(i,L)*2^(i-1),i=1..nops(L)) ;
    end proc:
  • Mathematica
    a[n_] := Partition[IntegerDigits[n, 2], 2, 1] /. {b_Integer, c_Integer} :> If[b == c, 1, 0] // FromDigits[#, 2]&;
    Table[a[n], {n, 0, 100}] (* Jean-François Alcover, Aug 08 2023 *)