GenerateRandomSearch

Sierpinski Fractal Generator

Both figures have a description that needs no recursion at all. A cell of the Sierpinski triangle is filled exactly when its row and column share no binary digit — the same pattern as Pascal's triangle modulo two. A cell of the carpet survives exactly when no base-three digit pair of its row and column are both one. Those rules produce the whole figure at once, and the counts they give, three and eight to the power of the depth, are what the page checks.

What this generator does

Fills a grid by testing each cell against a digit rule — binary for the triangle, base three for the carpet — and reports how many cells survived alongside the figure's fractal dimension.

How to use this tool

  1. Choose the triangle or the carpet.
  2. Set the depth — the carpet grows much faster, so its ceiling is lower.
  3. Read the filled-cell count and compare with the formula.
  4. Look at the dimension: between one and two for both.

Understanding the controls

Figure
The triangle, whose filled count is three to the depth, or the carpet, whose count is eight to the depth.
Depth
Up to 7 for the triangle and 4 for the carpet, since the carpet's cell count grows eight times faster per step.

Common use cases

  • Showing self-similarity with an exact count at every scale
  • Teaching the link between Pascal's triangle modulo 2 and the Sierpinski triangle
  • Generating fractal patterns for design work
  • Comparing two fractals with different dimensions side by side
  • Illustrating why the carpet fills less of the plane than it appears to

How this generator works

No recursion is involved. The triangle test is a single bitwise AND between the column and the row minus the column; the carpet test walks the base-three digits looking for a pair that are both one. The check confirms the count matches the formula, that no cell repeats, and that no triangle cell strays outside the triangle.

Randomness and fairness

Nothing here is random. The depth and the figure determine every cell, so there is no seed and no variation between runs.

For how randomness is produced across the whole site, see how Generate Random works.

Limitations and good to know

  • Triangle depth stops at 7 and carpet depth at 4, where each already has thousands of cells.
  • Only these two figures; the Menger sponge and other relatives are three-dimensional or otherwise out of scope.
  • Cells are drawn as squares, so the triangle is a stepped approximation rather than a smooth outline.
  • No colouring options beyond the accent colour.
  • Figures are not stored between visits.

Privacy and your data

Every cell is computed in your browser from a digit rule. Nothing is transmitted or stored.