[go: up one dir, main page]

login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

Depleted stream of the natural numbers written in base 2: delete even occurrences of digit 0 and odd occurrences of digit 1.
4

%I #14 May 12 2019 02:18:02

%S 0,1,1,0,1,0,1,1,1,0,0,1,0,1,0,1,1,1,0,1,0,1,1,1,1,0,0,1,0,0,1,0,1,0,

%T 1,0,1,0,1,0,1,1,0,1,1,1,0,0,1,0,1,1,0,1,1,1,0,1,1,0,1,1,1,1,1,0,0,0,

%U 1,0,0,1,0,0,1,0,1,0,1,0,0,1,0,1,0,1,0,1,1,0,1,0,0,1,0,1,0,1,0,1,1,0,1,0,1,1,0,1,1,0,1,1,1,1,0,0,1,0,0

%N Depleted stream of the natural numbers written in base 2: delete even occurrences of digit 0 and odd occurrences of digit 1.

%C The numbers in base 2: 0, 1, 10, 11, 100, 101, 110, 111, 1000, ....

%C The infinite stream of digits: 0110111001011101111000...

%C Delete even (2nd, 4th, 6th, ...) occurrences of 0 (replaced by ~):

%C 011~1110~10111~11110~0...

%C Delete odd (1st, 3rd, 5th, ...) occurrences of 1 (replaced by ~):

%C 0~1~~1~0~10~1~~1~1~0~0...

%C Digits remaining define the sequence: 0, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, ....

%p nb := 100 ;

%p L := [0] ;

%p for n from 1 to nb do

%p nn := ListTools[Reverse](convert(n,base,2)) ;

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

%p end do;

%p Lout := [] ;

%p ie :=1 ;

%p io :=1 ;

%p for i from 1 to nops(L) do

%p if op(i,L) =0 then

%p if ie>0 then

%p if type(ie,'odd') then

%p printf("%d,",0) ;

%p end if;

%p end if;

%p ie := ie+1 ;

%p else

%p if io>0 then

%p if type(io,'even') then

%p printf("%d,",1) ;

%p end if;

%p end if;

%p io := io+1 ;

%p end if;

%p end do: # _R. J. Mathar_, Dec 06 2011

%t nMax = 60; bits = Join @@ Table[IntegerDigits[n, 2], {n, 0, nMax}]; pos0 = Position[bits, 0] // Flatten; even0 = Partition[pos0, 2][[All, 2]]; bits2 = ReplacePart[bits, Alternatives @@ even0 -> "~"]; pos1 = Position[bits2, 1] // Flatten; odd1 = Partition[pos1, 2][[All, 1]]; DeleteCases[ ReplacePart[ bits2, Alternatives @@ odd1 -> "~"], "~"] (* _Jean-François Alcover_, Nov 18 2016 *)

%Y Cf. A174203, A174204 (base 10), A174205, A174206, A174208-A174210.

%K easy,nonn,base

%O 0,1

%A _Paolo P. Lava_ and _Giorgio Balzarotti_, Mar 15 2010