为什么不能用数组的思想呢?
class Fib(object): def __init__(self, num): Fib=[] if num>=0: Fib[0]=0 if num>=1: Fib[1]=1 if num>1: for i in range(1,num): Fib[i]=Fib[i-1]+Fib[i-2] self.name=Fib
class Fib(object): def __init__(self, num): Fib=[] if num>=0: Fib[0]=0 if num>=1: Fib[1]=1 if num>1: for i in range(1,num): Fib[i]=Fib[i-1]+Fib[i-2] self.name=Fib
2017-02-18
举报