Answer to Question #197867 in Python for LEROY

Question #197867
  1. Write a pseudocode a function called fibonacci that determines the first n terms of the Fibonacci sequence. The function should take n as an argument and return a list of the first n terms of the Fibonacci sequence. 

 


1
Expert's answer
2021-05-24T07:42:50-0400
def fib(n:int):
    a = list()
    for i in range(n):
        if i < 2:
            a.append(1)
        else:
            a.append(a[-1]+a[-2])
        print(a[i], end=' ')

fib(int(input()))

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS