+ 1

How do I right a simple python code to print Fibonacci number up say 21?

Fibonacci program

14th Nov 2017, 8:32 PM
Sipho Mazibuko
Sipho Mazibuko - avatar
3 Answers
17th Nov 2017, 1:26 AM
#RahulVerma
#RahulVerma - avatar
+ 5
https://code.sololearn.com/cbfGtdkZiI5s/?ref=app
14th Nov 2017, 8:51 PM
Baptiste E. Prunier
Baptiste E. Prunier - avatar
+ 1
________________________________________________________ # 1 Prints array of fibonacci items: def fibo(n): a, b, arr = 0, 1, [] while b <= n: arr.append(b) a, b = b, a + b return arr print fibo(21) ________________________________________________________ # 2 This one is more basic. Prints numbers each one in the next line def fibo(n): a, b = 0, 1 while b <= n: print b a, b = b, a + b fibo(21)
16th Nov 2017, 6:43 PM
Alexander Glinskiy
Alexander Glinskiy - avatar