## Java Nested Loop Sample Problem 1

For those who wish to improve their logical programming skills, we will be showing simple problems that can be solved using nested loops. Below is our first problem, where given a number will show a pattern. For example, if we are given the number 5, the output of our code should be:
*
**
***
****
*****

Below are more samples if we are given the input 1, 2, and 3:
*
Since input is 1, we will only have 1 line of output with one asterisks.
*
**
Since input is 2, we will only have 2 line in the output where the last line have 2 asterisks.
*
**
***
Since input is 3, we will only have 3 line in the output where the last line have 3 asterisks. The solution to this problem is given below:
```/**
* A simple program that outputs triangl pattern based on input.
*/
public class TriangleProgram {
public static void main(String[] args) {
drawTriangle(10);
}
private static void drawTriangle(int n) {
for (int i=1; i<=n; i++) {
for (int j=1; j<=i; j++) {
if (j==i) {
System.out.println("*");
} else {
System.out.print("*");
}
}
}
}
}
```

And here is a sample output if we run it with input 10:

*
**
***
****
*****
******
*******
********
*********
**********