First 'N' fibonacci numbers
First 'N' fibonacci numbers
Take a number (N) as input and print the first N fibonacci numbers separated by , (comma and a space)
Input:
20
Output:
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765
Challenge for you is that write a code for this in PYTHON!
All the best!
1 Answer
3 years ago by Sarvesh
def febo(items):
a = 0
b = 1
print(a)
print(b)
for n in range(0,items):
n = a + b;
print(n)
a=b
b=n
febo(20)
3 years ago by Srutiranjan Sarangi