Improve your programming skills

List of Fibonacci in Python and Fibonacci function

Fibonnaci in python by token:

# fibbonaci:
fib_list = [0, 1]
for i in range(10):
    fib_list.append(fib_list[-2] + fib_list[-1])

Or if You want Python function to generate Fibonacci

def funFibonaci(numberElements_in):
    fib_list = [0, 1]
    if numberElements_in == 1:
        return fib_list[-2]
    if numberElements_in == 2:
        return fib_list[-1]
    for i in range(numberElements_in-2):
        fib_list.append(fib_list[-2] + fib_list[-1])
    return fib_list


Leave a comment

Your email address will not be published. Required fields are marked *