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.

Showing 1-2 of 2 results.

A080116 Characteristic function of A014486. a(n) = 1 if n's binary expansion is totally balanced, otherwise zero.

Original entry on oeis.org

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
Offset: 0

Views

Author

Antti Karttunen, Feb 11 2003

Keywords

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

Examples

			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.
		

Crossrefs

Programs

  • 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 *)
  • 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
  • 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
    

Extensions

Examples added by Antti Karttunen, Aug 23 2019

A080113 Positions of A080115 in A000040.

Original entry on oeis.org

1, 7, 8, 10, 13, 14, 16, 18, 19, 21, 24, 25, 26, 28, 29, 30, 31, 33, 34, 35, 37, 38, 40, 41, 42, 44, 45, 47, 48, 49, 50, 51, 53, 55, 57, 59, 60, 61, 62, 63, 65, 66, 67, 68, 69, 70, 71, 73, 74, 75, 77, 78, 79, 80, 82, 84, 86, 87, 88, 89, 90, 91, 93, 94, 95, 97, 98, 99, 100, 101
Offset: 1

Views

Author

Antti Karttunen, Feb 11 2003

Keywords

Crossrefs

Complement of A080112. Characteristic function: A080111.

Programs

  • Maple
    A080113 := proc(n) option remember; local i; if(1 = n) then RETURN(1); fi; i := A080113(n-1)+1; while(i > 0) do if(A080111(i) > 0) then RETURN(i); fi; i := i+1; od; end;
  • Mathematica
    s[p_, u_] := Sum[JacobiSymbol[j, p], {j, 1, u}]; Join[{1}, Select[Range[ 100], !(p = Prime[#]; AllTrue[Range[(p - 1)/2], s[p, #] >= 0 &]) &]] (* Jean-François Alcover, Mar 07 2016 *)
Showing 1-2 of 2 results.