Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4
I only saw it now, that output shoud be horizontally. You can use this print statement instead of the one i postet: print (a, end = ', ') # output: 0, 1, 1, 2, 3, 5, 8,
23rd May 2019, 4:48 PM
Lothar
Lothar - avatar
+ 3
that’s the revised code: a, b= 0, 1 while (a<10): print (a) a, b= b, a+b
22nd May 2019, 6:37 PM
Lothar
Lothar - avatar
+ 2
hi, this code has some issues to run properly. 1 - indentation in line "while..." has to be removed 2 - " , end= 1,1" does not work and has to be removed print(a) is ok
22nd May 2019, 5:05 PM
Lothar
Lothar - avatar
+ 1
Hi Bhavya, this is a smart piece of code for Fibonacci series. Correct Program (after indentation correction): a, b= 0, 1 while (a<10): print (a) a, b= b, a+b this line: a,b = b, a+b is just swapping the value of a, b with b, a+b every time in the loop. Loop will at 8 number < 10. Hope, you've understood my point. Let me know in case if you're looking for more details. You can try in debug mode to understand the loops jumping and check step by step changes.
23rd May 2019, 11:55 AM
Mayank Baranwal
Mayank Baranwal - avatar
+ 1
This link may help you : https://www.tutorialgateway.org/JUMP_LINK__&&__python__&&__JUMP_LINK-fibonacci-series-program/ But, the output is in vertical form (code inside link)
23rd May 2019, 5:27 PM
$@G@®️
$@G@®️ - avatar
0
Where did you find this program? There are mistakes in it and the indentation is over the place...
22nd May 2019, 5:04 PM
HonFu
HonFu - avatar
0
idk if recursion works in javascript but i wrote a program in java that used recursion to write the fibonacci sequence
31st May 2019, 4:47 AM
Alexandra Gotschall
Alexandra Gotschall - avatar
- 4
3
23rd May 2019, 2:38 PM
Tom Mills