Skip to content
This repository has been archived by the owner on Dec 19, 2022. It is now read-only.

Create Pattern31.java #446

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions Java/Pattern Questions/Pattern31.java
Original file line number Diff line number Diff line change
@@ -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();
}
}
}