Programming Examples
Python program to generate in the Fibonacci series and store it in a list Then find the sum of all values
Write a program to generate in the Fibonacci series and store it in a list. Then find the sum of all values.
Solution
a=-1
b=1
n=int(input("Enter no. of terms: "))
i=0
sum=0
Fibo=[]
while i<n:
s = a + b
Fibo.append(s)
sum+=s
a = b
b = s
i+=1
print("Fibonacci series upto "+ str(n) +" terms is : " + str(Fibo))
print("The sum of Fibonacci series: ",sum)
Output
Enter no. of terms: 10
Fibonacci series upto 10 terms is : [0, 1, 1, 2, 3, 5, 8, 13, 21, 34]
The sum of Fibonacci series: 88