|
Triangle of Binary Digits
public
class BinaryTriangle
{
public static void main(String arg[])
{
String k = "1" , l = "" ,s =
"1";
int m = 0;
int n = 5
for(int i = 0; i < n; i++)
{
for(int j = 1; j < m; j++)
{
l += "0"
}
System.out.println(k + 1 + s +"\n");
l = "";
m += 2;
}
}
}
Output
:
1
1 0 1
1 0 0 0 1
1 0 0 0 0 0 1
1 0 0 0 0 0 0
0 1
|