Baum-Sweet Sequence Calculator

Sequences

Baum-Sweet value b(12)1
binary form of 121100
lengths of the zero blocks2
verdictno odd-length zero block
How this was calculated
  1. The Baum-Sweet sequence b(n) is 1 when the binary form of n has no block of consecutive zeros of odd length, and 0 when such a block occurs.
  2. The binary form of 12 is 1100, whose zero blocks have lengths 2.
  3. Every block has even length, so b(12) = 1.
  4. Leonard Baum and Melvin Sweet introduced the sequence in 1976 in a paper on continued fractions; it is automatic - a finite automaton reading the binary digits can decide it.

The Baum-Sweet sequence reads a number's binary form and asks one question about it: does any block of consecutive zeros have odd length? If yes, b(n) = 0; if no - including when there are no zero blocks at all - b(n) = 1. The first 16 values, from n = 0, are 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1: eight ones and eight zeros.

Two worked cases fix the rule. n = 12 is 1100 in binary: one zero block, of length 2 - even - so b(12) = 1. n = 10 is 1010: two zero blocks, each of length 1 - odd - so b(10) = 0. Note the trap the sequence sets: it is the blocks of zeros that matter, not the zeros themselves, and the leading digits are never padded - blocks are read from the ordinary binary form, which starts with a 1.

This Baum-Sweet sequence calculator reports the binary form, the lengths of every zero block, and the verdict for any n, and lists the first values from n = 0 with their one/zero counts. Leonard Baum and Elmer Sweet defined the sequence in 1976, in work on continued fractions - it encodes, in disguise, when a certain continued fraction stays bounded.

Worked examples

b(12)

(Value at n · 12)

Baum-Sweet value b(12)1
binary form of 121100
lengths of the zero blocks2
verdictno odd-length zero block

b(10)

(Value at n · 10)

Baum-Sweet value b(10)0
binary form of 101010
lengths of the zero blocks1, 1
verdictan odd-length zero block is present

First 16 values from n = 0

(First n values (from n = 0) · 16)

first 16 Baum-Sweet values (n = 0 to 15)1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1
ones among the values8
zeros among the values8
last value b(15)1

The zero-block rule

Write n in binary. Split the zeros into maximal blocks - maximal runs of consecutive 0 digits. If any block has odd length, b(n) = 0; otherwise b(n) = 1. The number 0 is assigned b(0) = 1 by convention, and every power of two has a single zero block (n = 8 is 1000, block length 3 - odd - so b(8) = 0; n = 4 is 100, block length 2, so b(4) = 1). The rule rewards even-length runs and punishes odd ones, regardless of position.

The calculator displays the block lengths as evidence: for 12 it shows binary 1100 with block lengths '2' and the verdict 'no odd-length zero block'; for 10 it shows 1010 with block lengths '1, 1' and the verdict 'an odd-length zero block is present'. The answer is never a bare bit - the reasoning is on the page.

  • Any odd-length zero block -> b(n) = 0
  • b(12) = 1 (1100, block length 2)
  • b(10) = 0 (1010, block lengths 1, 1)

The first 16 values

From n = 0: 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1. The ones and zeros split exactly 8 and 8 across this window, with the last value b(15) = 1 - 15 is 1111, no zeros at all, so nothing can be odd. Numbers with no zero blocks (one less than a power of two: 1, 3, 7, 15) always score 1, and they punctuate the list at positions 1, 3, 7, 15 - visible in the values above.

A subtle case the list exposes: b(6) = 0. Six is 110, a single zero block of length 1 - odd - hence 0. Trailing zero blocks count exactly like interior ones; the rule does not forgive a block for touching the end of the representation. Compare b(12) = 1 (1100, trailing block of length 2): the difference between 6 and 12 is one more zero, and it flips the bit.

Two families inside the list repay a second look. The values at n = 1, 3, 7, 15 are all 1 - these are the all-ones binary forms, with no zero blocks to judge. The values at the powers of two alternate with the exponent's parity: b(2) = 0 (10, one zero in a block of length 1), b(4) = 1 (100, block of length 2), b(8) = 0 (1000, block of length 3) - the single trailing block grows by one zero at each doubling, flipping the verdict every time. Between these landmarks the pattern is genuinely irregular, which is the expected texture of an automatic sequence: rigidly generated, locally unpredictable.

  • First 16 values: 8 ones, 8 zeros
  • b(15) = 1 - no zero blocks at all
  • Trailing blocks count: b(6) = 0, b(12) = 1

An automatic sequence with a theorem inside

Baum-Sweet is a 2-automatic sequence: a finite-state machine reading the binary digits of n can decide its value, tracking only whether it is inside a zero block and the parity of the current block's length. Yet it was not invented as a curiosity about automata. Baum and Sweet's 1976 paper studied continued fractions of power series, and the sequence records whether a related continued fraction has bounded partial quotients - an analytic property wearing binary clothes.

That dual nature is the sequence's charm: the definition fits in one sentence about zero blocks, the computation needs a two-bit state, and the meaning lives in Diophantine approximation. It stands with Thue-Morse and the paperfolding sequence in the family of automatic sequences that turned out to encode deep facts - all three appear in this batch of CalcForge pages, each computed from the binary anatomy of n in a different way.

  • 2-automatic: decided by a finite-state reader
  • Baum and Sweet, 1976, via continued fractions
  • Cousins: Thue-Morse, paperfolding

Reading the anatomy of n

Each automatic sequence in this family interrogates a different feature of the binary expansion. Thue-Morse counts the 1 digits mod 2. The paperfolding sequence strips factors of two and reads the odd part mod 4. Baum-Sweet inspects the 0 digits and reads block lengths mod 2. Same input anatomy, three different organs examined - which is why the three sequences look unrelated while being computed by sibling machines.

For a single number the contrast is instructive. n = 10 (1010): Thue-Morse gives t(10) = 0 (two 1s, even), paperfolding gives a(10) = 1 (odd part 5, which is 1 mod 4), and Baum-Sweet gives b(10) = 0 (zero blocks of length 1). Three bits, three different questions, no redundancy.

  • Thue-Morse: 1-digit parity
  • Paperfolding: odd part mod 4
  • Baum-Sweet: zero-block length parity

Edge cases and conventions

Three conventions are stated on the page and worth fixing in mind. First, b(0) = 1 by convention - the sequence starts at n = 0 with value 1. Second, binary forms are never padded: 5 is 101, not 0101, and padding would invent a leading zero block and change answers, so it is never done. Third, the number 1 in binary is '1' - no zero blocks - so b(1) = 1; likewise every repunit-in-binary number 2^k - 1 scores 1.

The parity subtlety that catches most people is the block, not the count: 10 has two zero digits in blocks of length 1 and scores 0, while 12 has two zero digits in one block of length 2 and scores 1. Same zeros, different blocking, different answer. If a hand computation disagrees with the calculator, the blocking is the first place to look.

  • b(0) = 1 by convention
  • Never pad the binary form
  • Blocks, not zero counts: 10 scores 0, 12 scores 1

Using the calculator

Value mode takes n up to 1,000,000 and returns b(n) with the binary form, the list of zero-block lengths, and the verdict sentence. List mode returns the first n values starting from n = 0, with the counts of ones and zeros and the last value - for 16 values, 8 ones and 8 zeros with b(15) = 1.

Try the powers of two in value mode - 4 (100, block 2, scores 1), 8 (1000, block 3, scores 0), 16 (10000, block 4, scores 1) - and the alternating verdicts lay the parity rule bare.

  • Value mode shows binary form and block lengths
  • List mode starts at n = 0 with counts
  • Powers of two alternate by block parity

FAQs

What is the Baum-Sweet sequence?

b(n) = 0 if the binary form of n contains a block of consecutive zeros of odd length, and 1 otherwise. It was defined by Baum and Sweet in 1976. Equivalently: scan the binary digits, and the value is 0 exactly when some run of zeros has odd length.

What is b(12)?

1. Twelve is 1100 in binary, with a single zero block of length 2 - even - so there is no odd-length zero block.

What is b(10)?

0. Ten is 1010 in binary, with two zero blocks each of length 1 - odd - so an odd-length zero block is present.

What are the first Baum-Sweet values?

From n = 0: 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1 - eight ones and eight zeros, ending with b(15) = 1.

Why does b(6) = 0 but b(12) = 1?

Six is 110 - a trailing zero block of length 1, odd, so 0. Twelve is 1100 - a trailing block of length 2, even, so 1. Trailing blocks count, and it is block lengths, not zero counts, that decide.

What is b(0)?

1, by convention - the sequence starts at n = 0 with value 1, and numbers with no zero blocks at all (like 1, 3, 7, 15) also score 1.

Sources

Related calculators

Thue-Morse Sequence Calculator
Compute Thue-Morse values t(n) from the parity of the binary digit sum - a single term or the first n terms of the overlap-free sequence.
Kolakoski Sequence Calculator
Generate the Kolakoski (Oldenburger-Kolakoski) sequence - the self-describing sequence of 1s and 2s that is its own run-length encoding.
Paperfolding Sequence Calculator
Compute the regular paperfolding sequence - the valley and mountain folds of a repeatedly folded strip, and the turn sequence of the dragon curve.