Question: This is what I need to do in Python. (We will pass in a value N. Write a program that outputs the complete Fibonacci sequence

This is what I need to do in Python. (We will pass in a value N. Write a program that outputs the complete Fibonacci sequence for N iterations.) This is my code however I am short by 1 iterations and cant figure out how to extend it by 1.

# Get N from the command line import sys N= int(sys.argv[1])

# Your code goes here def fib(N): f1 = 0 f2 = 1 f3 = 0 if N == 0: print(N) elif N == 1: print(f1) else: while f3 < N: print(f1) nth = f1 + f2 f1 = f2 f2 = nth f3 += 1 if N < 2: print (0) fib(N)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!