← all problems

printRightTriangle 🌶️

Write a method that takes one int parameter, n, and prints a right triangle of asterisks with n rows: row 1 has 1 asterisk, row 2 has 2, and so on up to row n, which has n asterisks. Use two loops — an outer loop for the row, and an inner loop to print that row's asterisks.

For example, printRightTriangle(3) prints:

******