Fibonacci a infinite loop? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Fibonacci a infinite loop?

This fibonacci serie code use decomposition and recursion to generate the serie, but it look like if it doesn't converge and the program never finish, it should work at least for 996 numbers. Someone can help me to understand or find the bug? Try with an input of 2 https://code.sololearn.com/c9c6jJ13gGiF/?ref=app

23rd Apr 2020, 5:57 AM
Diego Lesmes
Diego Lesmes - avatar
2 Answers
+ 5
You use bitwise or operator (|) in line #7 Replace it with conditional or: if n == 0 or n == 1:
23rd Apr 2020, 6:24 AM
andriy kan
andriy kan - avatar
+ 1
andriy kan Thanks a lot!!, What a bug jjeej
24th Apr 2020, 5:05 AM
Diego Lesmes
Diego Lesmes - avatar