Home > Article > Web Front-end > Recursively call function method
Recursive: Call yourself again inside a function;
Efficiency: This call has not yet ended , the next call will start, and this call will be suspended until all calls are completed before returning in sequence.
It is shaped like a mathematical function: the factorial of f(n)
##ex: 5!=5*4! (5* 4*3*2*1)
4!=4*3! (4*3*2*1)
3!=3*2! (3*2*1)
2!=2*1! ( 2*1)
##1!=1;
F(n)! =n*f(n-1)!
Exercise:
The following sequence: Fibonacci sequence
1,1,2,3,5,8,13 ,21,34,55………….
Known: The first number and the second number in the sequence are both 1
From the third Starting with numbers, each number is the sum of the previous two numbers
##
Document
The above is the detailed content of Recursively call function method. For more information, please follow other related articles on the PHP Chinese website!