Back To Java Loops Index
//program to input a number n and print pattern of numbers from 1 to n (example of nested loop) public class nestedforprintnos { public static void main(String[] args) { int n; int i,j; n=5; for(i=1;i<=n;i++) { for(j=1;j<=i;j++) { System.out.print(j); } System.out.println(); } } }