Example Analysis of Recursion in php
This article mainly introduces the example analysis of recursion in php, which has a certain reference value, and interested friends can refer to it. I hope you will gain a lot after reading this article.
Avoid using recursion
/ / Recursive function fibonacci ($n) {if ($n = = 0 | | $n = = 1) {return 1;} return fibonacci ($n-1) + fibonacci ($n-2);} / / non-recursive function fibonacci ($n) {$arr = [1mai]; for ($I = 2; $I < $n + 1; + + $I) {$arr [] = $arr [$I-1] + $arr [$I-2] } return $arr [$n];} Thank you for reading this article carefully. I hope the article "Recursive sample Analysis in php" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!