/********************* Happy Coding******************************/ package Amcat.pattern; public class Number2 { public static void patternGenerator(int n) { int j=n+1; boolean flag=true;//for odd lines ture else false int val=1; for(int i=1;i<=n/2;i++) { flag=true; j=n+1; for(int k=1;k<=j&&flag;k++) { System.out.print(val); } val++; System.out.println(val); System.out.print(val+1); for(int k=1;k<=j&&flag;k++) { System.out.print(val); } val++; System.out.println(); } } public static void main(String[] args) { patternGenerator(6); } }
Cracking Interviews = Easy + Fun Guides (DSA + System Design) 💡💻🚀