chapter_computational_complexity/exercises/ #1946
Replies: 8 comments
|
有习题了^_^ |
|
def fab(n: int) -> int:
a, b = 0, 1
while n:
a, b = b, a+b
n -= 1
return a还有斐波那契数列求和的循环算法 def F(n: int) -> int:
a, b = 0, 1
r = 0
while n > 1:
a, b = b, a+b
n -= 1
r += a
return r or n |
|
public class TestF { } |
|
int fibonacci(int n) } |
|
class Solution { |
|
#不使用递归的斐波那契数列 |
|
def fib(n): print(fib(5)) |
Uh oh!
There was an error while loading. Please reload this page.
chapter_computational_complexity/exercises/
动画图解、一键运行的数据结构与算法教程
https://www.hello-algo.com/chapter_computational_complexity/exercises/
All reactions