DEV Community

loading...

Day 7 of 100DaysOfCode: Python Code to Find Fibonacci Numbers Up To Given Number

iamdurga profile image Durga Pokharel ・1 min read

This is my 7th day of 100daysofcoding. I continue to learn from Coursera Python Data Structure course and also did some program regarding to some mathematical problems. I tired to write code to find Fibonacci numbers up to given number. My code is right below.

def fibonacci_number(n):
    a = 0
    b = 1
    fib = [a, b]

    for i in range(n):
        f = a + b
        a = b
        b = f
        fib.append(f)
    print(f"{fib}")
fibonacci_number(10)
Enter fullscreen mode Exit fullscreen mode

Discussion (2)

pic
Editor guide
Collapse
otumianempire profile image
Otu Michael

Every day I see you improve. And it is awesome.

Collapse
iamdurga profile image
Durga Pokharel Author

Thanks for your support 🙂