A061854 Nondiving binary sequences: numbers which in base 2 have at least the same number of 1's as 0's and reading the binary expansion from left (msb) to right (least significant bit), the number of 0's never exceeds the number of 1's.
1, 2, 3, 5, 6, 7, 10, 11, 12, 13, 14, 15, 21, 22, 23, 25, 26, 27, 28, 29, 30, 31, 42, 43, 44, 45, 46, 47, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 85, 86, 87, 89, 90, 91, 92, 93, 94, 95, 101, 102, 103, 105, 106, 107, 108, 109, 110, 111, 113, 114, 115, 116
Offset: 1
Examples
From _Hartmut F. W. Hoft_, Mar 29 2022: (Start) The columns in the table are the numbers n, the base-2 representation of n, the left half of the symmetric balanced string of parentheses corresponding to n, validity of the nondiving property for n, and associated number a(n): 1 1 ( True a(1) 2 10 () True a(2) 3 11 (( True a(3) 4 100 ()) False - 5 101 ()( True a(4) 6 110 (() True a(5) 7 111 ((( True a(6) 8 1000 ())) False - 9 1001 ())( False - 10 1010 ()() True a(7) ... 20 10100 ()()) False - 21 10101 ()()( True a(13) ... (End)
Links
- Harvey P. Dale, Table of n, a(n) for n = 1..1000
- R. K. Guy, Catwalks, sandsteps and Pascal pyramids, J. Integer Sequences, Vol. 3 (2000), Article #00.1.6.
- Antti Karttunen, Some notes on Catalan's Triangle
- Thomas Finn Lidbetter, Counting, Adding, and Regular Languages, Master's Thesis, University of Waterloo, Ontario, Canada, 2018.
- Index entries for sequences related to binary expansion of n
Crossrefs
Programs
-
Maple
# We use a simple backtracking algorithm: map(op,[seq(NonDivingLatticeSequences(j),j=1..10)]); NDLS_GLOBAL := []; NonDivingLatticeSequences := proc(n) global NDLS_GLOBAL; NDLS_GLOBAL := []; NonDivingLatticeSequencesAux(0,0,n); RETURN(NDLS_GLOBAL); end; NonDivingLatticeSequencesAux := proc(x,h,i) global NDLS_GLOBAL; if(0 = i) then NDLS_GLOBAL := [op(NDLS_GLOBAL),x]; else if(h > 0) then NonDivingLatticeSequencesAux((2*x),h-1,i-1); fi; NonDivingLatticeSequencesAux((2*x)+1,h+1,i-1); fi; end;
-
Mathematica
a061854[n_] := Select[Range[n], !MemberQ[FoldList[#1+If[#2>0, 1, -1]&, 0, IntegerDigits[n, 2]], -1]] a061854[116] (* Hartmut F. W. Hoft, Mar 29 2022 *) Select[Range[120],Min[Accumulate[IntegerDigits[#,2]/.(0->-1)]]>=0&] (* Harvey P. Dale, Sep 11 2023 *)
Comments