This is a creation in Article, where the information may have evolved or changed.
Overview
Premise: The number of endpoints is 1.
Each number equals two of the sum above it.
Each line of numbers is symmetrical, starting from 1 to become larger.
The number of the nth row has n items.
The nth row number and the 2n-1.
The number of m in the nth row can be expressed as C (N-1,m-1), which is the number of combinations that take m-1 elements from n-1 different elements.
The number of the nth row is equal to the number of n-m+1 and is one of the combinatorial number properties.
Each number equals the sum of the left and right two digits of the previous line. This property can be used to write out the entire Yang Hui triangle. That is, the number of n+1 in line I is equal to the sum of the number of i-1 and the number of the first n rows, which is also one of the properties of the combinatorial number. That is, C (n+1,i) =c (n,i) +c (n,i-1).
Each of the coefficients in the expansion of (A+B) n corresponds to each of the Yang Hui Triangle's (n+1) lines in turn.
The 1th digit of line 2n+1, followed by the 3rd number in line 2n+2, 5th of the 2n+3 line ... In the first line, these numbers are the 4n+1 Fibonacci numbers, and the 2nd number of rows 2n (n>1), followed by the 4th digit of line 2n-1, the 6th number of the 2n-2 line ... The sum of these numbers is the 4n-2 Fibonacci number.
The number of lines in the line, you can get 11 n-1 (n is the number of rows) the second side: 1=11^0; 11=11^1; 121=11^2 ... When the n≥5 will not conform to this property, at this time should be the nth line of the rightmost number "1″ in bits, and then the left of a number of digits aligned to 10 bits ..., and so on, the vacancy with" 0 ", and then add up all the numbers, the number is exactly 11 n-1. Take n=11 as an example, the number of the 11th line is: 1,10,45,120,210,252,210,120,45,10,1, the result is 25937424601=1110.
The code implementation of the Go language:
Package <textarea wrap="soft" class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;">mainimport ' FMT ' var a int = 10var triangle [10][10]intfunc Main () {for j: = 0; J < A, J + + {triangle[j][0] = 1TRIANGLE[J][J] = 1}for J: = 2; J < A; J + + {for n: = 1, n < J; n++ {triangle[j][n] = triangle[j-1][n-1] + triangle[j-1][n]}}for x: = 0; x < A; X + + {FMT. Print (x) for M: = A-x; M >= 0; m--{fmt. Print ("")}for N: = 0; n <= x; n++ {fmt. Print (Triangle[x][n], "")}fmt. Println ()}}</textarea>
| 1234567891011121314151617181920212223242526272829303132 |
Package MainImport "FMT"var a int = Tenvar Triangle [Ten][Ten]intfuncMain() { for J := 0; J < a; J++ {Triangle[J][0] = 1Triangle[J][J] = 1} for J := 2; J < a; J++ { for N := 1; N < J; N++ {Triangle[J][N] = Triangle[J-1][N-1] + Triangle[J-1][N]}} for x := 0; x < a; x++ {FMT.Print(x) for m := a - x; m >= 0; m-- {FMT.Print(" ")} for N := 0; N <= x; N++ {FMT.Print(Triangle[x][N], " ")}FMT.Println()}} |
:
go implementation of Yang Hui triangle output