Overview
Introduction
Gijswijt's sequence is one of the more famous curiosities in recreational number theory, a sequence so simply defined that it looks like it should behave predictably, yet its growth is notoriously erratic.
This generator computes the sequence term by term, applying the exact repeated-block rule that defines it, so you can see the pattern unfold for yourself.
What Is Generate Gijswijt's Sequence?
Gijswijt's sequence, cataloged as OEIS A090822, is a self-describing integer sequence where each term reflects how much repetition exists at the tail end of the sequence built so far.
It starts 1, 1, 2, 1, 1, 2, 2, 2, 3, 1, ... and famously takes an enormous number of terms before certain values, like 4, ever appear, making it a popular example of deceptive sequence growth.
How Generate Gijswijt's Sequence Works
To find the next term, the tool checks every possible block length ending at the current position, and for each length, checks how many times that block repeats consecutively right up to the end of the sequence.
The largest repeat count found across all block lengths, called the curling number, becomes the next term. If the sequence so far has no repeated block at all, the next term is 1 by definition.
When To Use Generate Gijswijt's Sequence
Use it for exploring self-describing sequences in recreational mathematics, or as a companion to Kolakoski Sequence Generator and Look-and-Say Sequence Generator when studying this family of sequences.
It's also a great demonstration piece for showing how a simple, deterministic rule can produce output that resists easy prediction.
Often used alongside Generate Kolakoski Sequence, Generate Look-and-Say Sequence and Generate Rudin-Shapiro Sequence.
Features
Advantages
- Implements the exact curling-number rule from the sequence's formal definition, not an approximation.
- Computes terms directly in the browser with no external lookup, so any valid term count within the limit produces a verified result.
- Clear, comma-separated output that's easy to scan for the sequence's characteristic runs of 1s and 2s.
Limitations
- Capped at 300 terms. The brute-force check for repeated blocks scales with the sequence length already built, so larger requests would take too long in a browser.
- Because of how rarely large values appear, a 300-term run is very unlikely to include anything beyond 1, 2, and 3.
Examples
Best Practices & Notes
Best Practices
- Generate at least 10-15 terms to see the first appearance of a 3, since the earliest few terms alone don't show the sequence's characteristic behavior.
- Don't expect to see a 4 in any practically sized run, it's known to first appear at an index far beyond what a browser-based generator can reach.
Developer Notes
The block-repeat check runs a nested loop over every candidate block length up to half the current sequence length, and for each length, every possible repeat count from the maximum down to 2, returning the first (largest) repeat count that matches, an O(n^2) to O(n^3)-ish brute force that's the reason for the 300-term cap.
Generate Gijswijt's Sequence Use Cases
- Exploring self-describing and curling-number sequences in recreational mathematics
- Classroom or self-study demonstrations of sequences with deceptively slow, hard-to-predict growth
- Generating verified reference terms to check a custom implementation of the curling-number rule
Common Mistakes
- Expecting to see a 4 appear in a short run, its first occurrence is astronomically far into the sequence and won't show up within the 300-term cap.
- Confusing the curling number rule with simple run-length encoding, it's about the longest repeated block ending at the current position, not just consecutive identical terms.
Tips
- Compare this sequence's growth pattern against Kolakoski Sequence Generator's output, both are self-describing but follow very different rules.
- If you're studying the curling number concept specifically, try generating terms at increasing counts to watch how long it takes for each new maximum value to appear.