Write a program to obtain the first 10 numbers of a Fibonacci sequence.
In a Fibonacci sequence the sum of two successive terms gives the third term.
Following are the first few terms of the Fibonacci sequence: 0 1 1 2 3 5 8 13 21 34 55 89...

Source Code

n = int(input("Enter number of terms required: "))
first=third=0
second=1
print(first,second,end=' ')
for i in range(3,n+1):
    third=first+second
    print(third,end=' ')
    first=second
    second=third

Output

Enter number of terms required: 10
0 1 1 2 3 5 8 13 21 34