login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A279645 a(n) = not (n XOR (n shift 1)). 3

%I #25 Mar 14 2024 12:14:50

%S 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,

%T 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,

%U 26,24,25,29,28,30,31,31,30,28,29,25,24,26,27,19,18,16

%N a(n) = not (n XOR (n shift 1)).

%C In other words, a(n) = the binary complement of (n XOR (n shift 1)). - _N. J. A. Sloane_, Mar 14 2024

%C Values of n for which a(n) = 0 are given by A000975(k).

%C Values of n for which a(n) = 1 are given by A097072(k) (for k>1).

%H Paolo P. Lava, <a href="/A279645/b279645.txt">Table of n, a(n) for n = 0..10000</a>

%H Paolo P. Lava, <a href="/A279645/a279645.txt">First occurrence of n in A279645, for n <= 1000</a>

%H Paolo P. Lava, <a href="/A279645/a279645.jpg">Graph of the first 10000 terms</a>

%H Paolo P. Lava, <a href="/A279645/a279645_1.jpg">Graph of the first occurrence of n in A279645, for n <= 1000</a>

%e 5044 converted to base 2 is 1001110110100.

%e Then consider each pair of adjacent bits starting from MSD: if they are equal, 00 or 11, set 1 otherwise 0:

%e (1+0) -> 0

%e (0+0) -> 1

%e (0+1) -> 0

%e (1+1) -> 1

%e (1+1) -> 1

%e (1+0) -> 0

%e (0+1) -> 0

%e (1+1) -> 1

%e (1+0) -> 0

%e (0+1) -> 0

%e (1+0) -> 0

%e (0+0) -> 1

%e We get 10110010001, so a(5044) = 1425.

%p P:=proc(n) local a,b,k; a:=0; b:=convert(n,base,2);

%p 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;

%p [seq(P(i),i=0..100)];

%p # alternative ( _R. J. Mathar_, Jun 22 2020)

%p A279645 := proc(n)

%p local dgs,L ;

%p dgs := convert(n,base,2) ;

%p L := [] ;

%p for i from 2 to nops(dgs) do

%p if op(i,dgs) = op(i-1,dgs) then

%p L := [op(L),1] ;

%p else

%p L := [op(L),0] ;

%p fi ;

%p end do:

%p add( op(i,L)*2^(i-1),i=1..nops(L)) ;

%p end proc:

%t a[n_] := Partition[IntegerDigits[n, 2], 2, 1] /. {b_Integer, c_Integer} :> If[b == c, 1, 0] // FromDigits[#, 2]&;

%t Table[a[n], {n, 0, 100}] (* _Jean-François Alcover_, Aug 08 2023 *)

%Y Cf. A000975, A038554, A097072.

%K nonn,easy,look

%O 0,7

%A _Paolo P. Lava_, Dec 16 2016

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 18 22:18 EDT 2024. Contains 371782 sequences. (Running on oeis4.)