📜  斐波那契数列 python 递归 - Python 代码示例

📅  最后修改于: 2022-03-11 14:47:18.909000             🧑  作者: Mango

代码示例2
# WARNING: this program assumes the
# fibonacci sequence starts at 1
def fib(num):
  """return the number at index num in the fibonacci sequence"""
  if num <= 2:
    return 1
  return fib(num - 1) + fib(num - 2)


print(fib(6))  # 8