Is there any way for PHP to get 10 lines of Yang Hui triangle?
This article will explain in detail how to get 10 lines of Yang Hui triangle in PHP. The content of the article is of high quality, so the editor will share it with you for reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.
Algorithm analysis: there is an array of I rows and j columns (j less than or equal to I)
1, double for loop, the first layer loop, traversing the array row I; the second layer loop, traversing the array column j. And the column j value of the array is less than or equal to the row I value of the array.
2. If statement is used in the body of the second layer loop to judge, and the value is $array [I] [j] = 1 when jroom1 or iRecij is used.
At other times, $array [I] [j] = $array [imur1] [jmur1] + $array [iMur1] [j]
Example