Staaarter

Generate Fibonacci Words

Generates the first N characters of the Fibonacci word, the binary Sturmian sequence built by repeatedly applying a = b, b = b + a starting from a = "0" and b = "01". A free online tool from Staaarter, right in your browser.

Runs locallyUpdated 2026-08-05
By Staaarter Team
fibonaccisequence

Overview

Introduction

The Fibonacci word takes the idea behind the Fibonacci numbers, each term built from the two before it, and applies it to strings instead of integers.

This tool builds the word up to whatever length you need and returns the first N characters, letting you inspect the sequence directly.

What Is Generate Fibonacci Words?

An infinite binary string, 0100101001001010010100100101001001..., generated by repeated concatenation rather than arithmetic.

Starting from a = "0" and b = "01", each construction round sets a to the previous b and b to the previous b concatenated with the previous a; as this repeats, b's prefix stabilizes, and that stable prefix is the Fibonacci word.

How Generate Fibonacci Words Works

The tool starts with a = "0" and b = "01", and repeatedly applies the update a, b = b, b + a until b is at least N characters long.

Because each round roughly multiplies the string's length by the golden ratio, only a small number of rounds are needed even for thousands of characters; the first N characters of the final b are returned.

When To Use Generate Fibonacci Words

Use it for combinatorics-on-words coursework, generating a Sturmian sequence example, or exploring aperiodic tilings and quasicrystal models that use the Fibonacci word as a reference structure.

It's also a compact way to demonstrate self-similar, non-repeating string structure without writing the construction code yourself.

Features

Advantages

  • Produces an exact prefix of the true infinite Fibonacci word, not an approximation.
  • Fast even at large character counts, since the underlying string roughly doubles in length every couple of construction rounds.
  • No special characters or encoding, the output is just 0s and 1s, easy to feed into other text tools.

Limitations

  • Capped at 5000 characters to keep the tool responsive; it isn't meant for generating enormous prefixes.
  • Only produces the standard Fibonacci word starting from a = "0", b = "01", it doesn't support alternate seeds or alphabets.

Examples

First 10 characters of the Fibonacci word

Input

10

Output

0100101001

The first 10 characters of the infinite sequence 0100101001001010010100...

First 5 characters of the Fibonacci word

Input

5

Output

01001

Best Practices & Notes

Best Practices

  • If you need to compare structure against the Tribonacci word, generate matching character counts from both tools for a fair side-by-side look.
  • Remember the string is 0-indexed from the very first character, there's no offset or header in the output.

Developer Notes

The implementation repeatedly applies `[a, b] = [b, b + a]` as plain string concatenation rather than tracking indices numerically, since string length after each round already tracks the Fibonacci numbers' growth; the loop exits as soon as `b.length` reaches the requested character count and the result is sliced to that exact length.

Generate Fibonacci Words Use Cases

  • Demonstrating Sturmian words and low-complexity aperiodic sequences in a combinatorics-on-words course
  • Generating reference data for quasicrystal or aperiodic-tiling models based on the Fibonacci word
  • Comparing self-similar string construction against the Tribonacci word's ternary analog

Common Mistakes

  • Expecting the output to contain digits other than 0 and 1, the Fibonacci word is strictly binary by construction.
  • Assuming the sequence eventually repeats, it provably never does, that's exactly what makes it a canonical example of an aperiodic Sturmian word.

Tips

  • Use Tribonacci Word Generator to see the natural ternary (ternary substitution) analog of this same idea.
  • Count the density of 0s versus 1s in a long prefix, it converges toward the golden ratio, a nice way to connect this back to the Fibonacci numbers themselves.

References

Frequently Asked Questions