Kotlinlearncs.online LogoJava
Return to List

Solve: Print Triangle Pattern

Created By: Justin Maier
/ Version: 2025.9.1

Write a function printTriangle that takes a single int argument and prints a right-triangled-shaped star pattern with as many rows as the argument.

For example, when the argument is 3 you should print the pattern:

*
**
***

When the argument is 4, you should print:

*
**
***
****

If the argument is 0 or less, print nothing.

Remember, you can use System.out.print to print without creating a new line.

Related Lessons

Stuck? You may find these lessons helpful: