The first step of Python3 programming _ Fibonacci sequence _ continuous assignment

 

1  # Fibonacci series: Fibonacci series 
2  # The sum of the two elements determines the next number 
3 a, b = 0, 1
 4  while b < 10 :
 5      print (b)
 6      a, b = b, a+ b
 7  # 1 1 2 3 5 8

 

Line 3, a=0, b=1

 

Line 6, inside the loop

The first time, a=1, b=1

The second time, a=1, b=2

The third time, a=2, b=3

4th time, a=3, b=5

5th time, a=5, b=8

6th time, a=8, b=13

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325026002&siteId=291194637