[Python] [25] [experimental demo includes exercises]

Original title:

A sequence Score: 2 / 1,3 / 2,5 / 3,8 / 5,13 / 8,21 / 13 ... and this calculated front 20 of the series.

 

My source:

# ! / Usr / bin / Python 
# encoding = UTF-8 
# - * - Coding: UTF-8 - * - 

#   has a sequence Score: 2 / 1,3 / 2,5 / 3,8 / 5,13 / 8 21/13 ... and this is determined before the series of 20. 

m = [1,2 ] 
n- = [2,3 ] 
S = 0
 for I in Range (20 is ):
     IF (len (m) <+ I. 1 ): 
        m.append (m [I -1] + m [ 2-I ]) 
        n.append (n-[I -1] n-+ [I-2 ]) 
    
    S = S n-+ [I] / m [I] 

Print ( " ########### ## " , S, " \ the n- ",m,"\n",n)
    
    

    
    
    
#第二种解法
o = [1,2]
t = 0
for i in range(0,20):
    if i >=1:
        o.append(o[i-1]+o[i])
    t = t + o[i+1]/o[i]

print("t",t)

 

Output:

 

 

 

Solution original title given by:

 

 

 

 

 

 


-------- (I am dividing line) --------

reference:

1. RUNOOB.COM:https://www.runoob.com/python/python-exercise-example24.html

 

 

Remarks:

Initial modified: October 3, 2019 16:20:28

Environment: Windows 7 / Python 3.7.2

 

Guess you like

Origin www.cnblogs.com/kaixin2018/p/11619993.html