Home  >  Article  >  Web Front-end  >  Recursively call function method

Recursively call function method

一个新手
一个新手Original
2017-09-21 09:54:501615browse

Recursive call (---Fibonacci sequence)

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

Question: Use a function to find the nth number in the sequence The value of

##



 
	 
     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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn