Created
September 17, 2015 18:20
-
-
Save vanjikumaran/0ca848fd7f0448501bc3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.lang.Math; | |
public class NxNPattern | |
{ | |
public static void main(String[] args) | |
{ | |
for (int i = 0, j = 0; i < 49; i++) { | |
if (i % 7 == 0) { | |
if (j > 0) System.out.println(); | |
j++; | |
} | |
int x = Math.abs(i % 7 - 3); | |
int y = Math.abs(j - 4); | |
if (x < y) System.out.print(y + 1); | |
else System.out.print(x + 1); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment