answersLogoWhite

0

Fibonacci sequence, also known as golden section sequence, is also known as "rabbit sequence" because mathematician Leonardoda Fibonacci introduced it by taking rabbit breeding as an example , refers to such a sequence: 1, 1, 2, 3, 5, 8, 13, 21, 34,... Mathematically, Fibonacci sequence is defined recursively as follows: F (1) = 1, f (2) = 1, f (n) = f (n-1) + F (n-2) (n > = 2, n ∈ n *)

The difficulty of Fibonacci sequence lies in the algorithm. If it becomes a generator, it needs to use the for loop to traverse the iteratable generator

The first recursive method

def fib_recur(n):

assert n >= 0, "n > 0"

if n 
User Avatar

George Durand

Lvl 3
3y ago

What else can I help you with?