Learn to Code : Fibonacci Sequence Generator

in coding •  5 months ago  (edited)

fibnac_gen.py


def fibonacci_sequence(n):
    sequence = [0,1]
    while len(sequence) < n:
        sequence.append(sequence[-1] + sequence[-2])
    return sequence

n_terms = int(input("Enter the number of terms in Fibonacci Sequence: "))
print(fibonacci_sequence(n_terms))
Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Upvoted! Thank you for supporting witness @jswit.