Showing posts with label Pascle triangle in java. Show all posts
Showing posts with label Pascle triangle in java. Show all posts

Sunday, 13 April 2014

Pascle Triangle

public class Pascal
{
int i,j,k,l=1;
void PrintPascal(int n)
{
for (i=1;i<=n;i++)
{
for(j=1;j<=n-i;j++)
{
System.out.print(" ");
}
for(k=0;k<i;k++)
{
System.out.print(i +" " );
}
System.out.println();
}
}
public static void main (String[] args)
{
Pascal p=new Pascal();
p.PrintPascal(5);
}
}
OUTPUT :  

    1
   2 2
  3 3 3
 4 4 4 4
5 5 5 5 5

Comment

Comments

Not using Html Comment Box  yet?

No one has commented yet. Be the first!

rss