References:

1.

History of the Basca Triangle

2.

Basca was a French mathematician in the 17th century, and the first person in history to invent an additive computer! He created the PASCAL triangle by writing out a row and a column of 1s on a piece of paper, then filling in the various positions with numbers, each of which was the sum of the number above it and the number to its left. Next, turn the table 45 degrees to the right, straighten it, and you get the number triangle!

3.

Math book, now called the triangle “PASCAL triangle”, in fact, in the math book, written by the southern song dynasty Yang hui jia xian already introduced by the northern song dynasty created the same triangle (in China, so called “jia xian triangle” or “Yang hui triangle”), time than PASCAL late in 600.

Combination number calculation method: C(n,m)=n! /[m!(n-m)!]

#include <stdio.h> #define N 12 long combi(int n, int r) { int i; long p = 1; for(i = 1; i <= r; i++) p = p * (n-i+1) / i; // The property of Sparka triangle is not adopted here, that is, the lower number is equal to the sum of the above two numbers, but through the relationship between columns and columns. // It can also be calculated using a two-dimensional array, where the bottom number equals the sum of the top two numbers. return p; }/** The above procedure is a recursive equation for solving the PASCAL triangle problem. Combi (0,0)->combi(1,0)->combi(1,1)->combi(2,0)->combi(2,1)->combi(3,1)-> combi(2,0)->combi(3,1)-> combi(2,1)->combi(3,1)-> There is no why, only how! Combi (0, 0) - > combi (1, 0) - > combi (1, 1) - > combi (2, 0) - > combi (2, 1) - > combi (3, 1) - >. I'm going to plug these in and get p and print! Just know how to do it! To get a little bit more advanced, you have to learn to derive your own formulas, which is the essence of real algorithms. **/ int main() { int n, r, t; for(n = 0; n <= N; n++) { for(r = 0; r <= n; r++) { int i; If (r == 0) {for(I = 0; i <= (N-n); i++) printf(" "); } else { printf(" "); */ printf("%3d", combi(n, r)); } printf("\n"); }}Copy the code