Posted by: Sourav | July 17, 2014

Pascal’s Triangle in Java


class pascal{

public static void main(String args[])

{

for(int i=0;i<=5;i++)
{
for(int j=(5-i);j>0;j–)
{
System.out.print(” “);
}

int num=(int)(Math.pow(11,i));

String s=String.valueOf(num);

//System.out.print(“len”+len);
for(int j=0;j<=((s.length())-1);j++)
{

System.out.print((s.charAt(j))+” “);

}

System.out.println();
}

}

}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: