Can I get a python code for the first N numbers of the Fibonacci series?

0 votes

Here is the python code for the first N numbers of the Fibonacci series.

# first n Fibonacci numbers

def fibonacciNumbers(n):

nums = []

a, b = 0, 1

for i in range(n):

nums.append(a)

a, b = b, a + b

return nums

if __name__ == "__main__":

print(fibonacciNumbers(10))

The above code will output the following numbers:

[0, 1, 1, 2, 3, 5, 8, 13, 21, 34]