Generate Thue-Morse Sequence

Generate the Thue-Morse sequence — a binary sequence (0, 1, 1, 0, 1, 0, 0, 1, ...) obtained by starting with 0 and repeatedly appending the complement. It is famously non-repeating and self-similar.

Options
Prouhet-Thue-Morse Generator Options
Start generating Thue-Morse numbers from this element.
How many iterations to generate?
Thue-Morse element separator.
(Newline \n by default.)
Output (Thue-Morse Sequence)

What It Does

Generate the Thue-Morse sequence — a binary sequence (0, 1, 1, 0, 1, 0, 0, 1, ...) obtained by starting with 0 and repeatedly appending the complement. It is famously non-repeating and self-similar.

How It Works

Generate Thue-Morse Sequence produces new output from rules, parameters, or patterns instead of editing an existing document. That makes input settings more important than input text, because the settings are what define the shape of the result.

Generators are only as useful as the settings behind them. When the output seems off, check the count, range, delimiter, seed values, or pattern options before judging the result itself.

All processing happens in your browser, so your input stays on your device during the transformation.

Common Use Cases

  • Study combinatorics on words
  • Generate fair division sequences (Thue-Morse is used for fair coin-toss alternatives)
  • Explore fractal and self-similar structures
  • Create non-repeating binary patterns for testing
  • Research overlap-free sequences

How to Use

  1. Specify how many terms to generate.
  2. Click Generate.
  3. View the binary sequence.
  4. Copy results.

Features

  • Generates the Thue-Morse sequence to any length
  • Shows the complementation construction
  • Binary and decimal representations
  • Highlights self-similar structure
  • Large sequence support

Examples

Below is a representative input and output so you can see the transformation clearly.

Input
SOS
Output
... --- ...

Edge Cases

  • Very large inputs can still stress the browser, especially when the tool is working across many numbers. Split huge jobs into smaller batches if the page becomes sluggish.
  • Empty or whitespace-only input is technically valid but may produce unchanged output, which can look like a failure at first glance.
  • If the output looks wrong, compare the exact input and option values first, because Generate Thue-Morse Sequence should be repeatable with the same settings.

Troubleshooting

  • Unexpected output often means the input is being split or interpreted at the wrong unit. For Generate Thue-Morse Sequence, that unit is usually numbers.
  • If a previous run looked different, check for hidden whitespace, changed separators, or a setting that was toggled accidentally.
  • If nothing changes, confirm that the input actually contains the pattern or structure this tool operates on.
  • If the page feels slow, reduce the input size and test a smaller sample first.

Tips

The Thue-Morse sequence solves the 'fair division' problem: if two players take turns in Thue-Morse order (ABBABAAB...) instead of alternating (ABABAB...), the advantage of going first is minimized.

The Thue-Morse Sequence

Start with 0. Append the complement: 01. Append the complement of that: 0110. Again: 01101001. Each step doubles the length. The sequence begins: 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, .... Alternatively, T(n) equals the number of 1s in the binary representation of n, modulo 2.

Properties

The Thue-Morse sequence is overlap-free (no substring of the form aXaXa appears), cube-free, and has no period. It has applications in fair division, chess tournament scheduling, signal processing, and fractal generation. The Koch snowflake can be constructed using Thue-Morse turtle graphics.

Frequently Asked Questions

How is the sequence constructed?

Start with 0. At each step, append the bitwise complement of the current sequence. 0 → 01 → 0110 → 01101001 → ....

What makes it 'fair' for division?

If two players choose in Thue-Morse order (ABBABAAB...) instead of simple alternation (ABABAB...), the first-mover advantage is minimized because the sequence balances the distribution over time.

Is the sequence periodic?

No. The Thue-Morse sequence never repeats. It is aperiodic.

What is the connection to binary representations?

T(n) = (number of 1-bits in n) mod 2. Numbers with an even count of 1-bits get 0; odd count gets 1.

Where is it used in mathematics?

In combinatorics on words, fractal geometry, fair division theory, and as a counterexample in various combinatorial problems.

Can it be generalized?

Yes. The Thue-Morse sequence generalizes to arbitrary alphabets and higher-dimensional analogs.