We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 67e49a6 + bb2f9aa commit ee80badCopy full SHA for ee80bad
sierpinski.java
@@ -0,0 +1,28 @@
1
+import java.util.*;
2
+import java.io.*;
3
+class sierpinski
4
+{
5
+ static void printSierpinski(int n)
6
+ {
7
+ for (int i = n - 1; i >= 0; i--) {
8
+ for (int j = 0; j < i; j++) {
9
+ System.out.print(" ");
10
+ }
11
+ for (int k = 0; k + i < n; k++) {
12
+ if ((k & i) != 0)
13
+ System.out.print(" "+" ");
14
+ else
15
+ System.out.print("* ");
16
17
+ System.out.print("\n");
18
19
20
+ public static void main(String args[])
21
22
+ int n;
23
+ Scanner s= new Scanner(System.in);
24
+ n= s.nextInt();
25
+ printSierpinski(n);
26
27
+}
28
+
0 commit comments