Code:
public class Pattern
{
public static void main(String[] args)
{
for (int i = 1; i <=8; i++)
{
int b=1;
for(int j = 1; j < 2*i; j+=2)
{
System.out.print(b+" ");
if(j == 2*i - 1)
{
int c = b/2;
for(int k=j-1; k >=1; k-=2)
{
System.out.print(c+" ");
c=c/2;
}
}
b=b*2;
}
System.out.println();
}
}
}
No comments:
Post a Comment