I wrote a short code which outputs the first n numbers of the Fibonacci sequence where n is the value of the passed parameter and each number is printed in a new line. My problem is that the output isn't starting at 0, it starts at 1. How do I also get the 0 in the output?
def fibonacci(n):
fib1 = 0
fib2 = 1
for x in range(0,n):
print("%d\n" %(fib2), end = " ")
next = fib1 + fib2
fib1 = fib2
fib2 = next
So this is the output, why are the numbers after the first one moved in? output