This article details python output the Fibonacci series. This article details python output the Fibonacci series.
Def recur_fibo (n): "recursive function output Fibonacci sequence" if n <= 1: return n else: return (recur_fio (n-1) + recur_fio (n-2 )) # obtain the input nterms = int (input ("How many items do you want to output? ") # Check whether the entered number is correct if nterms <= 0: print (" input positive number ") else: print (" Fibonacci sequence: ") for I in range (nterms): print (recur_fibo (I ))
# Output the first 20 Fibonacci series to the list a = 0b = 1i = 0 fibo = [] while True: I + = 1 if I <= 10: fibo. append (a) fibo. append (B) a + = B + = a else: print (fiber) print (len (fiber) break
The above is a detailed description of the Fibonacci series output by python. For more information, see other related articles in the first PHP community!