- 1

I am a beginner in Python. I want to code a program which outputs all the Fabonacci numbers within 100.

For example: 0 1 1 2 3 5 8 13 21 34 ... I tried this piece of code: num1 = 0 num2 =1 num3 = num2 + num1 while num3 <= 100: print(num3) num2 = num3 num1 = num2

21st Aug 2021, 3:13 PM
Sunny
Sunny - avatar
2 Antworten
+ 1
Correct code, num1 = 0 num2 =1 num3 = num2 + num1 while num3 <= 100: print(num3) num1,num2=num2,num3 num3=num2+num1
21st Aug 2021, 3:24 PM
Abhay
Abhay - avatar
+ 1
Thank u both of u.. I'll try these and then let u know if it worked...
22nd Aug 2021, 4:29 AM
Sunny
Sunny - avatar