返回列表 發帖
  1. def compute(n):
  2.     if n==0:
  3.         return 0
  4.     elif n==1:
  5.         return 1
  6.     else:
  7.         return compute(n-1)+compute(n-2)
  8.         
  9.    
  10. n=int(input())        
  11. for i in range(int(n),0,-1):
  12.     t=compute(i)
  13.     print(f"fib({i})={t}")
複製代碼
回復 1# 鄭繼威

TOP

返回列表