Fibonacci sequence Fibonacci Sequence, also known as the Golden section of the series, refers to such a series: 0, 1, 1, 2, 3, 5, 8, 13, 、...... Mathematically, the Fibonacci sequence is defined as a recursive method: F (0) =0,f (1) =1,f (n) =f (n-1) +f (n-2) (n≥2,n∈n*)
There are a pair of one-month-old male and female rabbits, in another one months when mating rabbits, assuming they are born of two a male and female rabbit, at the end of the next month these two rabbits also have offspring is also a male and female, the question is how many rabbits will you have in a year? [Bared teeth] the third year was like going to Australia ...
def fib (x): if or x==1:return 1 else:return fib (x-1) +fib (x-2) >> > fib (233>>>) fib (75025>>> fib)
MIT Python Fourth Lesson function abstraction and recursion The classic case of the last three minutes recursion: Fibonacci sequence