Baum-Sweet Numbers Generator
Generate the Baum-Sweet sequence b(n). Find which integers have binary representations with no odd-length blocks of consecutive zeros.
Configure parameters above and click Generate to compute the Baum-Sweet sequence.
| n | Binary | Zero-blocks | b(n) |
|---|
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).
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.
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
| n | Binary | Zero-blocks | b(n) | Reason |
|---|---|---|---|---|
| 0 | 0 | [1] | 0 | Block of length 1 (odd) |
| 1 | 1 | - | 1 | No zero-blocks |
| 2 | 10 | [1] | 0 | Block of length 1 (odd) |
| 3 | 11 | - | 1 | No zero-blocks |
| 4 | 100 | [2] | 1 | Block of length 2 (even) |
| 5 | 101 | [1] | 0 | Block of length 1 (odd) |
| 6 | 110 | [1] | 0 | Block of length 1 (odd) |
| 7 | 111 | - | 1 | No zero-blocks |
| 8 | 1000 | [3] | 0 | Block of length 3 (odd) |
| 9 | 1001 | [2] | 1 | Block of length 2 (even) |
| 10 | 1010 | [1, 1] | 0 | Both blocks odd |
| 11 | 1011 | [1] | 0 | Block of length 1 (odd) |
| 12 | 1100 | [2] | 1 | Block of length 2 (even) |
| 13 | 1101 | [1] | 0 | Block of length 1 (odd) |
| 14 | 1110 | [1] | 0 | Block of length 1 (odd) |
| 15 | 1111 | - | 1 | No zero-blocks |
| 16 | 10000 | [4] | 1 | Block of length 4 (even) |
| 17 | 10001 | [3] | 0 | Block of length 3 (odd) |
| 18 | 10010 | [2, 1] | 0 | Second block odd |
| 19 | 10011 | [2] | 1 | Block of length 2 (even) |
| 20 | 10100 | [1, 2] | 0 | First block odd |
| 33 | 100001 | [4] | 1 | Block of length 4 (even) |
| 36 | 100100 | [2, 2] | 1 | Both blocks even |
| 39 | 100111 | [2] | 1 | Block of length 2 (even) |
| 48 | 110000 | [4] | 1 | Block of length 4 (even) |
| 51 | 110011 | [2] | 1 | Block of length 2 (even) |
| 63 | 111111 | - | 1 | No zero-blocks |
| 64 | 1000000 | [6] | 1 | Block of length 6 (even) |
| 100 | 1100100 | [2, 1] | 0 | Second block odd |
| 255 | 11111111 | - | 1 | No zero-blocks |
| 256 | 100000000 | [8] | 1 | Block of length 8 (even) |