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!)
A080116 Characteristic function of A014486. a(n) = 1 if n's binary expansion is totally balanced, otherwise zero. 6
1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 (list; graph; refs; listen; history; text; internal format)
OFFSET
0,1
COMMENTS
a(n) = 1 if the binary representation of n forms a valid Dyck path, or equally, a well-formed parenthesization when 1's are converted to left and 0's to right parentheses (that is, when A007088(n) is in A063171), and 0 otherwise. - Antti Karttunen, Aug 23 2019
LINKS
EXAMPLE
0 stands for an empty parenthesization, thus a(0) = 1.
2 has binary expansion "10", which corresponds with "()", thus a(2) = 1.
3 has binary expansion "11", but "((" is not a well-formed parenthesization, thus a(3) = 0.
10 has binary expansion "1010", corresponding with a well-formed parenthesization "()()", thus a(10) = 1.
38 has binary expansion "100110", but "())(()" is not a well-formed parenthesization, thus a(38) = 0.
MAPLE
A080116 := proc(n) local c, lev; lev := 0; c := n; while(c > 0) do lev := lev + (-1)^c; c := floor(c/2); if(lev < 0) then RETURN(0); fi; od; if(lev > 0) then RETURN(0); else RETURN(1); fi; end;
MATHEMATICA
A080116[n_] := (lev = 0; c = n; While[c > 0, lev = lev + (-1)^c; c = Floor[c/2]; If[lev < 0, Return[0]]]; If[lev > 0, Return[0], Return[1]]); Table[A080116[n], {n, 0, 104}] (* Jean-François Alcover, Jul 24 2013, translated from Maple *)
PROG
(Sage)
def A080116(n) :
lev = 0
while n > 0 :
lev += (-1)^n
if lev < 0: return 0
n = n//2
return 0 if lev > 0 else 1
[A080116(n) for n in (0..104)] # Peter Luschny, Aug 09 2012
(PARI) A080116(n) = { my(k=0); while(n, k += (-1)^n; n >>= 1; if(k<0, return(0))); (0==k); }; \\ Antti Karttunen, Aug 23 2019
CROSSREFS
Sequence in context: A016378 A323513 A089805 * A016359 A014029 A016396
KEYWORD
nonn,base
AUTHOR
Antti Karttunen, Feb 11 2003
EXTENSIONS
Examples added by Antti Karttunen, Aug 23 2019
STATUS
approved

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 August 23 21:15 EDT 2024. Contains 375396 sequences. (Running on oeis4.)