0

Fibonacci series

Could you please let me know why this python code to print Fibonacci series up to 100 prints even 144 https://code.sololearn.com/c5B505VWVKNl/#py

20th Jul 2020, 8:58 PM
Expensive Harmonica
Expensive Harmonica - avatar
2 Réponses
+ 3
you check if a<n before you add to it, so 89<100 = true 89+55 = 144 print(144) 144<100 = false so loop terminates here after already printing 144
20th Jul 2020, 9:05 PM
JME
0
Thanks JME
20th Jul 2020, 10:12 PM
Expensive Harmonica
Expensive Harmonica - avatar