pattern_21.java
1 /* 2 * Write code to print the following pattern 3 * 1 2 3 4 5 4 * 2 3 4 5 6 5 * 3 4 5 6 7 6 * 4 5 6 7 8 7 * 5 6 7 8 9 8 */ 9 10 public class pattern_21 { 11 public static void main(String[] args) { 12 int n = 5; 13 14 for(int i = 1; i <= n; i++) { 15 for(int j = i; j <= (i + 4); j++) { 16 System.out.print(j + " "); 17 } 18 System.out.println(); 19 } 20 } 21 }