diff --git a/Java/Pattern Questions/Pattern31.java b/Java/Pattern Questions/Pattern31.java new file mode 100644 index 00000000..e5f00c0c --- /dev/null +++ b/Java/Pattern Questions/Pattern31.java @@ -0,0 +1,16 @@ +public class Pattern31 { + public static void main(String[] args) { + pattern31(5); + } +static void pattern31(int n) { + int originalN = n; + n = n * 2; + for (int row = 1; row < n; row++) { + for (int col = 1; col < n; col++) { + int atEveryIndex = originalN - Math.min(Math.min(row, col), Math.min(n - row, n - col)); + System.out.print(atEveryIndex + 1 + " "); + } + System.out.println(); + } + } +}