User Rating 0.0
Total Usage 0 times
Min: 0
Max: 100,000
Non-negative integer, max 100,000
Max: 100,000
Presets:
𝔹

Configure parameters above and click Generate to compute the Baum-Sweet sequence.

Total 0
b(n)=1 0
b(n)=0 0
Density 0%
Density of b(n)=1
0%
n = 0
Binary: 0
Zero-blocks: —
b(n) = 0
nBinaryZero-blocksb(n)
Is this tool helpful?

Your feedback helps us improve.

About

The Baum-Sweet sequence, introduced by Leonard Baum and Melvin Sweet in 1976, maps each non-negative integer n to a binary value b(n) based on the structure of its binary representation. Specifically, b(n) = 1 if and only if every contiguous block of 0s in the binary expansion of n has even length. A single misidentified block leads to an incorrect classification. The sequence appears in formal language theory, automatic sequences, and fractal geometry. This generator computes b(n) directly from binary decomposition without lookup tables. It handles n = 0 as a special case (b(0) = 1 by convention in OEIS A086747, though some authors define b(0) = 0; this tool follows the convention where the binary of 0 is "0", containing a single zero-block of odd length 1, hence b(0) = 0).

baum-sweet sequence binary sequence number theory integer sequence combinatorics OEIS A086747

Formulas

For a non-negative integer n, compute the Baum-Sweet value b(n) as follows. Let s be the binary string representation of n. Extract all maximal contiguous runs of the digit 0 from s. Denote these zero-blocks as z1, z2, …, zk with respective lengths l1, l2, …, lk.

b(n) = {
1 if len(zi) 0 (mod 2) for all i0 if i such that len(zi) is odd

Equivalently, using regular expressions on the binary string: b(n) = 1 if and only if the binary representation matches the pattern ^1([01]*1)?$ where no 0-run has odd length. The implementation splits the binary string by 1s, filters non-empty segments, and verifies each segment length is even.

Where b = Baum-Sweet value (0 or 1), n = non-negative integer input, s = binary string of n, zi = the i-th maximal zero-block in s, and len(zi) = length of that block.

Reference Data

nBinaryZero-blocksb(n)Reason
00[1]0Block of length 1 (odd)
11 - 1No zero-blocks
210[1]0Block of length 1 (odd)
311 - 1No zero-blocks
4100[2]1Block of length 2 (even)
5101[1]0Block of length 1 (odd)
6110[1]0Block of length 1 (odd)
7111 - 1No zero-blocks
81000[3]0Block of length 3 (odd)
91001[2]1Block of length 2 (even)
101010[1, 1]0Both blocks odd
111011[1]0Block of length 1 (odd)
121100[2]1Block of length 2 (even)
131101[1]0Block of length 1 (odd)
141110[1]0Block of length 1 (odd)
151111 - 1No zero-blocks
1610000[4]1Block of length 4 (even)
1710001[3]0Block of length 3 (odd)
1810010[2, 1]0Second block odd
1910011[2]1Block of length 2 (even)
2010100[1, 2]0First block odd
33100001[4]1Block of length 4 (even)
36100100[2, 2]1Both blocks even
39100111[2]1Block of length 2 (even)
48110000[4]1Block of length 4 (even)
51110011[2]1Block of length 2 (even)
63111111 - 1No zero-blocks
641000000[6]1Block of length 6 (even)
1001100100[2, 1]0Second block odd
25511111111 - 1No zero-blocks
256100000000[8]1Block of length 8 (even)

Frequently Asked Questions

The binary representation of 0 is the string "0", which contains exactly one zero-block of length 1 (odd). By the strict block-parity rule, b(0) = 0. Some authors define the sequence starting at n = 1 or use a convention where the empty product yields 1. OEIS A086747 (which counts indices where b(n) = 1) does not include 0. This tool applies the definition uniformly.
The density of 1s in the Baum-Sweet sequence tends to 0 as n . Among the first N terms, the count of 1s grows roughly as Nd where d 0.732 (related to the Hausdorff dimension of the associated Cantor-like set). This means for large ranges, the majority of values will be 0.
The Baum-Sweet sequence is a 2-automatic sequence, meaning it can be computed by a finite automaton reading the base-2 digits of n. The automaton has 3 states: one accepting state (all zero-blocks so far have even length), one transient state (currently inside a zero-block of odd cumulative length), and one rejecting sink state (an odd-length zero-block was completed). This makes it a regular sequence in the formal language sense.
Yes. The computation for each n is O(log n) since it only examines the binary digits. JavaScript safely handles integers up to 253 1. This tool caps at 100,000 for UI responsiveness when generating ranges, but individual lookups could handle much larger values with trivial modification.
Plotting indices where b(n) = 1 reveals a self-similar fractal structure. The set of such indices forms a Cantor-like set in base 2: numbers whose binary expansions avoid odd-length zero-blocks. Powers of 4 (1, 4, 16, 64, …) always satisfy b(n) = 1 because 4k in binary is 1 followed by 2k zeros (even length). Similarly, all Mersenne-type numbers 2k 1 (all-ones binary) always yield 1.
Both are 2-automatic sequences but measure different binary properties. The Baum-Sweet sequence checks zero-block parity. The Rudin-Shapiro sequence counts the number of overlapping occurrences of the pattern "11" in the binary expansion modulo 2. They have different asymptotic densities and fractal dimensions. The Rudin-Shapiro sequence maintains a density of exactly 0.5 for both values, while the Baum-Sweet 1-density decays to zero.