Hello everyone , I meet you again , I'm your friend, Quan Jun .
**
**
The Fibonacci sequence refers to a sequence that looks like this 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233,377,610,987,1597,2584,4181,6765,10946,17711,28657,46368…
This sequence starts at number one 3 A start , Each of these terms is equal to the sum of the first two terms .
In the computer , First, press all the parameters of the process to the bottom of the stack , Subroutine calls , Finally, get the parameters at the bottom of the stack
def fibonacci(n):
if n == 0:
return 0
elif n == 1:
return 1
else:
return fibonacci(n-1) + fibonacci(n-2)
print([fibonacci(x) for x in range(10)]
Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/150693.html Link to the original text :https://javaforall.cn