Functions - Fibonacci series - Number of terms

# Functions - Fibonacci series - Number of terms

def fn_fib(nterms):
    n1 = -1
    n2 = 1
    for counter in range(0,nterms,1):
        fib = n1 + n2
        print(fib, end = " ")
        n1, n2 = n2, fib

# Main Program

no_of_terms = int(input("Enter number of terms :"))
print("Fibonacci series : ")
fn_fib(no_of_terms)

No comments:

Post a Comment

Don't be a silent reader...
Leave your comments...

Anu