C++ Saved Program: quiescent-mountain

facebook share

Here's the online compiler accompanied with IDE at your service. This is a saved code by one of our users. Try it out or save your own from the IDE page and don't forget to leave a feedback. You can find that at the bottom of the page.


l=[]
n = int(input("How many terms in sequence to generate :> "))
first = 0
l.append(str(first))
second = 1
l.append(str(second))

sum = 1
for i in range(2,n):
    term = first + second
    sum = sum + term
    l.append(str(term))
    
    first = second
    second = term
print(",".join(l))
print("The sum of all terms is :> ",sum)
Execute

Output

Press the execute button or CTRL + enter to run code.

Inputs