Star Triangle

Lab Java Beginner 10 points

Read n and print a right triangle of stars with n rows (row i has i stars).

Input

One integer.

Output

n rows.

Example

Input

4

Output

*
**
***
****
Sample input available Sample output available
Editor
Java

Hints

The inner loop runs i times on row i.

Solution explanation

Nested loops: the outer one picks the row, the inner one fills it.

Show solution
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        for (int i = 1; i <= n; i++) {
            for (int j = 0; j < i; j++) {
                System.out.print('*');
            }
            System.out.println();
        }
    }
}
Output
Answer
HOME LEARN COMMUNITY DASHBOARD