用python求前四十個斐波那契數

#求前40個斐波那契數 #方法1 L=[] a=0 b=1 n=0 while n<40: L+=[b] a,b=b,a+b n+=1 print("前四十個斐波那契數有:",L) print("----------------") #方法2 L=[] for s in range(40): if s==0 or s==1: L.append(1)
相關文章
相關標籤/搜索