Fibonacci Sequence in Python

This program generates the Fibonacci sequence up to a given number of terms.

 
n = int(input("Enter the number of terms: "))
t1, t2 = 0, 1
print("Fibonacci Series:", t1, t2, end=", ")
for _ in range(3, n + 1):
    nextTerm = t1 + t2
    print(nextTerm, end=", ")
    t1, t2 = t2, nextTerm

No comments:

Post a Comment

MS Excel Logical Functions

Logical functions in Excel are powerful tools that help you make decisions based on conditions. Whether you're comparing values or testi...

Post Count

Loading...