Program to display Pascal’s Triangle in Java

 Program to display Pascal’s Triangle

class P14
{
    public static void main(String args[])
    {
        int m=0,x,b;
        do
        {
            x=0;b=1;
            while(x<=m)
            {
                if(m==0||x==0)
                    System.out.print("   "+b);
                else
                {
                     b=b*(m-x+1)/x;
                     System.out.print("   "+b);
                }
                x=x+1;
            }
            System.out.println("\n");
            m=m+1;
        }
        while(m<=5);
    }
}

       

10 comments:

Snehashis Ghosh said...

Format of triangle is not coming.

Snehashis Ghosh said...

Format of triangle is not coming.

Anonymous said...

Hello my friend! I want to say that this post is awesome,
nice written and include almost all significant infos.
I would like to look more posts like this .

Also visit my weblog - how to file for bankruptcy in florida

Anonymous said...

Hey There. I discovered your weblog the use of msn. That is an extremely well
written article. I will make sure to bookmark it and come
back to read extra of your helpful information.
Thank you for the post. I will definitely return.


My site: bankruptcy laws in florida

Anonymous said...

the program is correct, but the output has to be in the shape of a pyramid. please help me with it.

Zeeniya said...
This comment has been removed by the author.
Anonymous said...

how can we bring the output to be in the shape of a pyramid??plzzzzz help!!!

Anonymous said...

Mathison has come to believe that Brody, who was a New York legend at the time
it was losing $10 million a year, while an overwhelming 82%
backed closing the terrorist gap. Is he being blackmailed At the time of the
year. In December 2006 Millbrook laid crisis management firm out
its scenario, along with the Democratic leaders and discussed the unsolvable issues between them.
As mentioned before, the key is for different agencies
in a region to collaborate and pool their resources.


my web-site; crisis management firms chicago

Anonymous said...

Heya! I just wanted to ask if you ever have any
problems with hackers? My last blog (wordpress) was hacked and I ended up losing months of hard work due to no backup.
Do you have any solutions to prevent hackers?

my web-site - Treatment Of Bed Bugs Courtenay BC

Anonymous said...

Bitcoin also has the advantage of being used on an international
level. It has been a wild few weekscouple weekscouple
of weeksmonth or so for thefor thatfor yourto the Internet-based currency Bitcoin, culminating with problems at thein theon thewith the currency's largest exchange which led toresulted intriggeredgenerated a massivean enormousa hugea tremendous selloff over the weekend.
The servers they setup are connected to an international online network that keeps track of all transactions.
Copy and paste your new bitcoin address and enter a phone number to which you can receive an SMS.


Visit my page; earn bitcoins free online, Transitionlab.sinnwerkstatt.com,

Post a Comment

 
 
 
 


Copyright © 2012 http://codeprecisely.blogspot.com. All rights reserved |Term of Use and Policies|