This file contains hidden or 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
| public class ChessPattern { | |
| public static void main(String[] args) { | |
| int n = 5; | |
| for (int i = 0; i < n; i++) { | |
| for (int j = 0; j < n; j++) { | |
| if (i % 2 == 0) | |
| System.out.print("* "); | |
| else | |
| System.out.print(" *"); | |
| } |
This file contains hidden or 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
| public class HollowPyramid { | |
| public static void main(String[] args) { | |
| int n = 5; | |
| for (int i = n - 1; i >= 0; i--) { | |
| for (int j = 0; j <= i; j++) { | |
| if (j == 0 || i == n - 1 || i == j) | |
| System.out.print("* "); | |
| else | |
| System.out.print(" "); | |
| } |
This file contains hidden or 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
| public class Reels { | |
| public static void main(String[] args) { | |
| int n=5; | |
| for (int i = 0; i < n; i++) { | |
| for (int j = 0; j < n - i; j++) { | |
| System.out.print(" "); | |
| } | |
| for (int j = 0; j < i; j++) { | |
| System.out.print("* "); | |
| } |
This file contains hidden or 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
| public class Reels { | |
| public static void main(String[] args) { | |
| int n = 5; | |
| for (int i = n; i > 0; i--) { | |
| for (int j = 0; j < i; j++) { | |
| System.out.print("* "); | |
| } | |
| System.out.println(); | |
| } | |
| } |
This file contains hidden or 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
| public class Reels { | |
| public static void main(String[] args) { | |
| int n = 5; | |
| for (int i = 0; i < n; i++) { | |
| for (int j = 0; j < n; j++) { | |
| if (i == 0 || j == 0 || i == n - 1 || j == n - 1) { | |
| System.out.print("* "); | |
| } else { | |
| System.out.print(" "); | |
| } |
This file contains hidden or 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
| public class Reels { | |
| static void printPattern(int n) { | |
| int counter = 1; | |
| for (int i = 0; i < n; i++) { | |
| for (int j = 0; j < n; j++) { | |
| if (i >= j) { | |
| System.out.print(counter + " "); | |
| counter++; | |
| } | |
| } |
This file contains hidden or 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
| public class Reels { | |
| static void fib(int m, int n, int maxx) { | |
| int nxt = m + n; | |
| if (nxt <= maxx) { | |
| System.out.print(nxt + " "); | |
| fib(n, nxt, maxx); | |
| } | |
| return; | |
| } |