+ 11

I need a python code for this pattern!

0,1,1,2,3,5,8,13,.... can anyone suggest me Python code for this pattern using loop

29th Mar 2018, 2:01 PM
Shadow Windster
Shadow Windster - avatar
8 Answers
+ 6
Here is what I came up with. Please note that I'm not a Python developer and haven't touched it since Python 2, so forgive me for my noobness with it. lol https://code.sololearn.com/csmv4n6ob6NQ/#py startingVal = 0 endingVal = 1 while True: result = startingVal + endingVal print(result) endingVal = startingVal startingVal = result if result > 20: break ::::: OUTPUT :::::: 1 1 2 3 5 8 13 21
29th Mar 2018, 2:15 PM
Fata1 Err0r
Fata1 Err0r - avatar
29th Mar 2018, 2:11 PM
Hatsy Rei
Hatsy Rei - avatar
+ 4
@Turtle 0 + 1 = 1 1 + 1 = 2 2 + 1 = 3 3 + 2 = 5 5 + 3 = 8 8 + 5 = 13
29th Mar 2018, 2:12 PM
Fata1 Err0r
Fata1 Err0r - avatar
+ 3
This is the same code from Fata Err0r https://code.sololearn.com/cJt07H84WDgf/#py Except i changed some of the code.(really small changes)
14th Apr 2018, 12:06 PM
syul
syul - avatar
+ 2
@Jakob Marley Oh thanks
29th Mar 2018, 2:15 PM
TurtleShell
TurtleShell - avatar
+ 1
@Turtle Anytime bro!
29th Mar 2018, 2:19 PM
Fata1 Err0r
Fata1 Err0r - avatar
- 2
I don't see a pattern
29th Mar 2018, 2:10 PM
TurtleShell
TurtleShell - avatar