pytho查找斐波那契序列中的值

'''
实现斐波那契序列,查找其中第N个数的值

'''

def  FeiBSequence(list,N):
    length=len(list);
    i=0;
    while i<length:
        if N<=2 and N>0:
            return list[N-1];
            break;
        else:
            z=list[i]+list[i+1];
            list.append(z);
            i+=1;
            length+=1;
            if length==N:
                print list;
                return list[N-1];                
                break;
if __name__ == '__main__':
    print FeiBSequence([1,3],5);
    
原文地址:https://www.cnblogs.com/mlmy/p/6308688.html