The Sierpinski triangle of order 0 is a single star. A triangle of order n is made of three triangles of order n − 1: one on top, one at the bottom left, one at the bottom right.
Write Sierpinski: read the order n (0 to 6) and draw the triangle on a grid of characters with a recursive method
draw(order, top, centre) // a triangle whose top star is at row 'top', column 'centre'
A triangle of order n is 2ⁿ rows high; its three parts are placed at (top, centre), (top + half, centre − half) and (top + half, centre + half) with half = 2ⁿ⁻¹. Print the grid without spaces at the end of the lines, then the number of stars and of calls. For the input
3
the program prints
*
* *
* *
* * * *
* *
* * * *
* * * *
* * * * * * * *
Order 3: 27 stars, 40 calls
Before running it for order 5: how many stars, and how many calls?