Classical algorithm-(c) Pascal Triangle (Yang Hui triangle)

Source: Internet
Author: User

The Yang Hui triangle is a geometric arrangement of the two-item coefficients in a triangle. In Europe, the table is called the Pascal Triangle. Pascal (1623----1662) discovered this rule in 1654, 393 years later than Yang Hui, and 600 years later than Jia Xian.

Brief introduction:

The Yang Hui triangle is a geometric arrangement of the two-item coefficients in a triangle. In Europe, the table is called the Pascal Triangle. Pascal (1623----1662) discovered this rule in 1654, 393 years later than Yang Hui, and 600 years later than Jia Xian. The Yang Hui Triangle is one of the outstanding research achievements in ancient Chinese mathematics, it is a kind of discrete number and shape, it is the graph of the two-item coefficients, and the algebraic properties inherent in the combinatorial number are visualized from the graph.

Result: (The arrangement looks a bit irregular due to two-digit and one-digit reasons)

Java implementations:

 PackageA;ImportJava.math.BigInteger;ImportJava.util.*; Public classmain{ Public Static  voidMain (string[] args) {System.out.println ("Please enter n"); Scanner Cin=NewScanner (system.in);  while(Cin.hasnext ()) {intn=Cin.nextint (); int[] A=New int[N+1] [N+1];  for(inti=0;i<n;i++) {                 for(intk=0;k<n-i;k++) {System.out.print ("  "); }                 for(intj=0;j<i+1;j++) {                    if(j==0| | J==n-1) {A[i][j]=1; }                    Else{A[i][j]=a[i-1][j-1]+a[i-1][j]; } System.out.print (A[i][j]+"  ");            } System.out.println ();            }} cin.close (); }}

Classical algorithm-(c) Pascal Triangle (Yang Hui triangle)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.