Paperfolding Sequence Generator
Generate regular paperfolding sequences (dragon curve sequences) with custom symbols, directions, and instant download.
What is the Paperfolding Sequence?
The regular paperfolding sequence (also known as the dragon curve sequence) is an infinite automatic binary sequence of 1s and 0s. It represents the sequential directions of creases created when folding a strip of paper repeatedly in half in one direction, and then unfolding it to form 90-degree angles.
How is the Sequence Generated?
Imagine folding a long strip of paper in half from right to left.
- First Fold: Creates a single crease pointing upwards (represented as $1$ or 'U').
- Second Fold: Creates two additional creases, resulting in a sequence of three creases: $1, 1, 0$ (or 'Up, Up, Down').
- Third Fold: Results in seven creases: $1, 1, 0, 1, 1, 0, 0$.
Mathematically, the $n$-th term $a_n$ (for $1$-based index $n \ge 1$) can be computed directly using the following formula:
Write $n$ in the form $2^k(2m+1)$ where $k \ge 0$ and $m \ge 0$. Then:
- $a_n = 1$ if $m$ is even ($m \equiv 0 \pmod 2$).
- $a_n = 0$ if $m$ is odd ($m \equiv 1 \pmod 2$).
The Connection to the Dragon Curve Fractal
If you unfold the paper so each crease forms a perfect 90-degree angle, the strip forms the geometric path of the **Heighway Dragon Curve** (or dragon fractal). By using $1$ as a right turn and $0$ as a left turn, the paperfolding sequence provides the exact, infinite instruction set required to draw this beautiful fractal pattern step-by-step.
How to Use the Paperfolding Sequence Generator
Our online generator makes exploring paperfolding sequences quick and customizable:
- Enter the Number of Terms you want to generate (up to 10,000).
- Customize the Symbols for '1' (Up/Right fold) and '0' (Down/Left fold). You can use U/D, R/L, or any custom characters.
- Choose a Separator (comma, space, new line, semicolon, pipe) or select "None" for a continuous stream of folds.
- Turn on the Show 1-Based Index Labels to view the exact folding step count next to each fold direction.
- Click Generate to see the results instantly, then easily copy the text or download it as a
.txtfile.
Frequently Asked Questions
What does "aperiodic" mean in relation to paperfolding?
It means that no matter how far you extend the paperfolding sequence, it will never settle into a repeating cycle of fold patterns. It remains completely deterministic but never repeats cyclically.
How does this sequence relate to binary numbers?
The value of the $n$-th crease depends on the position of the lowest set bit in the binary representation of $n$. This property makes it easy to calculate any arbitrary term $a_n$ in constant time.
Is there a limit to how many terms I can generate?
The generator is optimized to create up to 10,000 terms instantly in your browser. All calculations run client-side for absolute privacy and performance.
Can I use this sequence to draw the dragon curve?
Absolutely! If you interpret the symbols as directions (e.g. 1 = turn right, 0 = turn left) and draw segments of equal length, you will trace the exact path of the Heighway Dragon.
Related tools
Your recent visits