Get the App
SLTechnology News&Howtos  ›  Development  › 

Is there any way for PHP to get 10 lines of Yang Hui triangle?

Shulou Source: shulou.com Published: 2022-06-03 17:32:31 09月29日 Update

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

Tags: Loops arrays methods Yang Hui triangles Yang Hui triangle one line two layers location content articles more knowledge articles good sum digits instances loop body time Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno Huawei Apple Microsoft Redmi