Draw a Sierpinski Fractal
Report the triangle count, area and perimeter of a Sierpinski triangle after n steps, from a side length you type.
Count, area and perimeter
The Sierpinski triangle keeps three half-size triangles from each filled one: the three corner triangles, with the middle removed. Step n therefore holds 3^n triangles. The area starts at root three over four times the side squared and is multiplied by three quarters at every step, while the perimeter starts at three times the side and is multiplied by three halves. The page prints all three figures.
The two measures move in opposite directions, which is the definition of a fractal here: the area falls toward zero while the perimeter grows without bound. Both are closed forms in n, so the page multiplies rather than recursing and cannot hang.
Steps are capped at ten, where the count is 59,049. The side must be above zero and the step count a whole number between zero and ten; anything else is refused with the reason rather than clamped.
A Sierpinski triangle keeps three half-size triangles from each one, so step n holds 3^n triangles, the area falls by three quarters per step and the perimeter grows by three halves. The page prints all three figures, and stops at 10 steps, where the count is 59,049 triangles.
How to use it
Enter the starting side and the number of steps, then press Run. The first line is the triangle count, the second the area left, and the third the total perimeter. The starting area is printed beside the surviving area so the fall is visible without arithmetic.
The arithmetic
Each step keeps three of the four half-size triangles, so the count is 3^n, the area is root three over four times the side squared times three quarters to the n, and the perimeter is three times the side times three halves to the n. Area and perimeter move in opposite directions, which is the property the page is built to show.
Where it stops
This page reports the measures rather than drawing the triangle; the family's canvas pages draw their shapes. Zero side is refused because a triangle with no side has no area, a fractional step is refused, and the cap of 10 keeps the perimeter comparable with the start.
What to Expect
Best for
- students meeting fractal dimension
- checking a Sierpinski construction
What this tool keeps
- the triangle count, the remaining area and the perimeter
Sample input
Side 100, 4 steps
Sample output
Triangles = 81 Area = 1370.0793 (starting 4330.127) Perimeter = 1518.75
Frequently asked questions
How do I use the Sierpinski counter?
Type a starting side length and a whole number of steps, then press Run. The page prints the triangle count, the remaining area and the perimeter, so the two measures can be compared side by side.
Is anything uploaded?
No. The three closed forms are evaluated in this tab with JavaScript: no request is made, no account is needed, nothing is stored, and the page keeps working offline once loaded.
What are its limits?
The side must be above zero and the steps must be a whole number from 0 to 10. Ten steps is 59,049 triangles, and the perimeter is already about fifty-eight times the starting triangle's, so a deeper count describes a shape no drawing can show.
Build custom tools for your store
Join the SDK program to create useful ecommerce utilities for your store.