Machine Problem 1-2
Create a Python program that displays the Fibonacci sequence up to 20 values. The program should contain loop and def functions.
DS100-1
3Q1920Info! Broken links? Email us at gtechphofficial@gmail.com
Code:
def fib(value):
previous=0
result=0
current=1
ls = [previous, current]
for i in range(value-2):
result = current + previous
previous = current
current = result
ls.append(result)
return ls
print("The first 20 Fibonacci numbers are: " + str(fib(20)))