Skip to content

Patterns

Read · 1 of 3

Let the row decide

For a triangle, row i has i stars, so the inner loop goes up to i instead of a fixed number.

For shapes with leading spaces, print the spaces first (another inner loop), then the stars.

1*
2**
3***