User Rating 0.0
Total Usage 0 times
0 ≤ n ≤ 99,999
1 ≤ count ≤ 10,000
Presets:
Configure parameters and press Generate to compute the Baum-Sweet sequence.
Is this tool helpful?

Your feedback helps us improve.

About

The Baum-Sweet sequence, introduced by L. E. Baum and M. M. Sweet in 1976, is a binary-valued sequence indexed by non-negative integers. For each n, the term b(n) equals 1 if and only if the binary expansion of n contains no block of consecutive zeros whose length is odd. Otherwise b(n) = 0. The sequence begins 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1 (OEIS A086747). It arises in the study of algebraic power series over finite fields and connects number theory to formal language theory. Misidentifying zero-block parity leads to incorrect classification of algebraic irrationals over F2. This generator computes exact values and exposes the binary structure so you can verify each term against its zero-run decomposition.

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

Formulas

The Baum-Sweet sequence is defined by inspecting the binary representation of each non-negative integer for contiguous runs of zeros.

b(n) = {
1 if n = 01 if every maximal block of consecutive zeros in bin(n) has even length0 otherwise

Where bin(n) denotes the binary string of n without leading zeros. A maximal block is a contiguous substring of 0s not extendable left or right. The algorithm scans this string with a regular expression matching pattern 0+ to extract all zero runs, then checks the length parity of each.

Equivalently, b(n) = 1 if and only if n can be written as n = ki=0 ai 4ci where each ai {1, 2, 3} and ci are distinct non-negative integers. This base-4 characterization proves no digit equals 0 in the base-4 representation.

Where: b(n) = the Baum-Sweet term at index n; bin(n) = binary representation of n; ai = base-4 digits of n.

Reference Data

nBinaryZero Runsb(n)
00 - 1
11none1
2101 (odd)0
311none1
41002 (even)1
51011 (odd)0
61101 (odd)0
7111none1
810003 (odd)0
910012 (even)1
1010101, 1 (odd)0
1110111 (odd)0
1211002 (even)1
1311011 (odd)0
1411101 (odd)0
151111none1
16100004 (even)1
17100013 (odd)0
18100102, 1 (odd)0
19100112 (even)1
20101001, 2 (odd)0
21101011, 1 (odd)0
22101101, 1 (odd)0
23101111 (odd)0
24110003 (odd)0
25110012 (even)1
26110101, 1 (odd)0
27110111 (odd)0
28111002 (even)1
29111011 (odd)0
30111101 (odd)0
3111111none1

Frequently Asked Questions

The convention follows the original 1976 paper by Baum and Sweet. The value n = 0 is treated as a special case: its binary representation is considered to have no zero blocks (since there is no non-trivial binary expansion). Equivalently, in base-4, 0 has no digits at all, satisfying the condition vacuously. Every standard reference (OEIS A086747, Allouche & Shallit) sets b(0) = 1.
A zero run of even length 2k in binary corresponds to a factor of 4^k, which is absorbed into the base-4 digit structure. A zero run of odd length would require a base-4 digit of 0 (since an isolated 0 bit cannot pair with an adjacent 0 to form a complete base-4 digit). Therefore b(n) = 1 if and only if no base-4 digit of n equals 0. This gives an O(log n) algorithm: convert to base 4 and check for any 0 digit.
The density of 1s tends to 0. More precisely, the number of indices k ≤ n with b(k) = 1 grows as O(n^(log 3 / log 4)) ≈ O(n^0.7925). This sub-linear growth means 1s become increasingly sparse. The exponent log₄(3) arises because in base 4, each digit has 3 out of 4 non-zero choices, giving 3^d valid numbers with d digits.
Yes. The Baum-Sweet sequence is 2-automatic, meaning it can be generated by a deterministic finite automaton with output (DFAO) reading the base-2 digits of n. The automaton has 3 states: state 0 (start, output 1), state 1 (inside even-length zero run, output 1), and state 2 (trap, output 0). Transitions: from state 0, reading 1 stays at 0, reading 0 goes to 1. From state 1, reading 0 goes to 0, reading 1 goes to 0. From state 2, all inputs stay at 2. State 1 reading 1 goes to 0 (even zero block closed), but if state 1 reads end-of-input, output 0 (odd zero block). The exact automaton varies by formulation but the sequence is provably 2-automatic.
Baum and Sweet proved that the generating function f(x) = Σ b(n)·x^n satisfies the cubic equation f³ + x·f + 1 = 0 over the field F₂. This means f(x) is algebraic of degree 3 over F₂(x). The sequence was originally constructed to study the continued fraction expansion of algebraic elements in the field of formal Laurent series over F₂. It demonstrated that algebraic irrationals over finite fields can have bounded partial quotients, contrasting with open conjectures for real algebraic irrationals.
Each term requires converting n to binary (O(log n) time) and scanning for zero runs (O(log n) time). For 10,000 terms the total work is roughly 10,000 × 17 bits ≈ 170,000 character operations. This completes in under 50ms on modern hardware. The generator caps at 10,000 terms per batch to keep the DOM responsive. For individual lookups, any n up to 2^53 − 1 (JavaScript safe integer limit) works correctly.