当前位置:网站首页>Fibonacci number

Fibonacci number

2022-07-06 00:47:00 々 orange if ℃ №

Learning goals :

A daily topic - Fibonacci number


Learning content :

Fibonacci number ( Usually use F(n) Express ) The sequence formed is called Fibonacci sequence . The sequence is composed of 0 and 1 Start , Each of the following numbers is the sum of the first two numbers . That is to say :
 Insert picture description here
solution :

class Solution:
    def fib(self, n: int) -> int:
        if n == 0:
           return 0
        if n == 1:
            return 1
        return self.fib(n-1)+self.fib(n-2)

 Insert picture description here

原网站

版权声明
本文为[々 orange if ℃ №]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202140211540970.html