fibonacci never attaining output | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 2

fibonacci never attaining output

a = 0 b = 1 while a < 21: a # so we know what variable we are focusing on b, a + b, b else: while a > 21: print(a) a, b = b + a, b #the computer is lying. why doesn't it count over 20?

2nd Nov 2019, 10:23 PM
sudo-asap
sudo-asap - avatar
2 Respostas
+ 4
a_s_a_p First, a computer can not lie, and second, it's better to learn the basics first. For learning the basics please take a look at some Tutorials like sololearn. You will find many more Tutorials in the web. https://code.sololearn.com/crmosLd7oU6t/?ref=app Take a look at this code for compute the fibonacci series. Regards kiuziu
3rd Nov 2019, 12:16 AM
Kiuziu šŸ’˜ Berlin
Kiuziu šŸ’˜ Berlin - avatar
+ 3
The computer is not lying. You've created a while loop which keeps looping while a < 21 but you don't change the value of a. If the code ever got past your first while loop, it would throw an error because you don't use an else statement with a while loop.
2nd Nov 2019, 10:49 PM
Russ
Russ - avatar