Php recursion. I read php recursion on the Internet just now, and asked me again, telling me that recursion is called itself. Did not understand. I also read the Quita issue on Baidu. Actually, I know what is going on with the tower, but I still don't understand recursion. Hope you can give us an easy-to-understand example..., function & nbsp; f ($ n) & nbsp; php recursion.
I read php recursion on the Internet just now, and asked me again, telling me that recursion is called itself. Did not understand. I also read the Quita issue on Baidu. Actually, I know what is going on with the tower, but I still don't understand recursion. Hope that the ox people will give an easy-to-understand example...
------ Solution --------------------
Function f ($ n)
{
$ Out =-1;
If ($ n <0)
Echo "the input cannot be a negative number ";
Else if ($ n = 0
------ Solution --------------------
$ N = 1)
$ Out = 1;
Else $ out = f ($ n-1) * $ n;
Return $ out;
}
Echo f (3 );
The most typical example is factorial.