← Unit 2 · all exercises
Saved in this browser only

A triangle of stars

Print a triangle: one star on the first line, two on the second, and so on down to n. Use no spaces.

void triangle(int n)

Solution.java
Loading editor…
Results

Examples

  • triangle(3) → * ** ***
  • triangle(1) → *

There are also 2 hidden tests you can't see. Solve the problem, not the examples.