In the above Java program to print a right angles triangle from a number, we have use nested loop where i is row and j is column in that row.
import java.util.Scanner;
public class pattern {
public static void main(String[] args)
{
int i,j,n;
System.out.print("Input number of rows : ");
Scanner in = new Scanner(System.in);
n = in.nextInt();
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
System.out.print(j);
System.out.println("");
}
}
}
Sample Output: Input number of rows : 10 1 12 123 1234 12345 123456 1234567 12345678 123456789 12345678910