Skip to content

Instantly share code, notes, and snippets.

@rohityadavcloud
Created November 23, 2022 12:53
Show Gist options
  • Save rohityadavcloud/1a332e9be8d45d43f158674c288bfb5f to your computer and use it in GitHub Desktop.
Save rohityadavcloud/1a332e9be8d45d43f158674c288bfb5f to your computer and use it in GitHub Desktop.
ChristmasTree
public class ChristmasTree {
public static void main(String[] args) {
for (int i = 0; i < 10; i++) {
for (int j = 0; j < 10 - i; j++) {
System.out.print(" ");
}
for (int k = 0; k < (2 * i + 1); k++) {
System.out.print("*");
}
System.out.println();
}
System.out.println(String.format("%12s", "| |"));
}
}
/*
Output:
*
***
*****
*******
*********
***********
*************
***************
*****************
*******************
| |
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment