🐍 Enter a number and have the program generate the Fibonacci sequence to that number or to the Nth number.
a = 0
b = 1
d = []
for x in range(n):
d.append(a)
c = a
a = b
b += c
return d
if __name__=='__main__':
num = int(input('Enter a number between 1 and 100: '))
print(fib(num))
Solution
def fib(n):a = 0
b = 1
d = []
for x in range(n):
d.append(a)
c = a
a = b
b += c
return d
if __name__=='__main__':
num = int(input('Enter a number between 1 and 100: '))
print(fib(num))
Comments
Post a Comment