filmov
tv
Master Python's Fibonacci Sequence with This Simple DSA Algorithm for Beginners!

Показать описание
Discover how to master the Fibonacci sequence using Python with this straightforward DSA (Data Structures and Algorithms) tutorial. Whether you're a beginner or looking to brush up on your coding skills, this video breaks down the Fibonacci algorithm step by step, helping you understand and implement this essential concept in Python. Perfect for students, developers, and coding enthusiasts who want to enhance their algorithmic thinking.
def fibonnaci(n):
#let's sequence starts from 0, 1
sequence = [0,1]
#now create for loop
#why 2, n because 0,1 already we had in sequence
#now n will be input from user
for i in range(2,n):
next_number = sequence[-1] + sequence[-2]
#[-1] means last value from sequence list & -2 means second last value
#from sequence list..
return sequence
#let's call function now
print(fibonnaci(9))
def fibonnaci(n):
#let's sequence starts from 0, 1
sequence = [0,1]
#now create for loop
#why 2, n because 0,1 already we had in sequence
#now n will be input from user
for i in range(2,n):
next_number = sequence[-1] + sequence[-2]
#[-1] means last value from sequence list & -2 means second last value
#from sequence list..
return sequence
#let's call function now
print(fibonnaci(9))