+ 1

Logic

x = 1 while (x<=5): x+=x print (x)

29th Oct 2018, 10:24 AM
AMAN TOMAR
AMAN TOMAR - avatar
6 Answers
0
AMAN TOMAR Because x will have following values (every line represent x value at start and at end of any iteration starting from first): at start:1 at end:2 at start:2 at end:4 at start:4 at end:8 because 8 is not <=5, no more iterations happen then x value is 8 after while
29th Oct 2018, 2:05 PM
KrOW
KrOW - avatar
+ 3
why the ans is not 10
29th Oct 2018, 10:37 AM
AMAN TOMAR
AMAN TOMAR - avatar
+ 3
thanks a ton KrOW
29th Oct 2018, 2:12 PM
AMAN TOMAR
AMAN TOMAR - avatar
+ 2
Jay Matthews please help me with the logic
29th Oct 2018, 10:31 AM
AMAN TOMAR
AMAN TOMAR - avatar
+ 1
👍👍👍
29th Oct 2018, 2:12 PM
KrOW
KrOW - avatar
+ 1
8
9th Feb 2020, 1:34 AM
Manasa
Manasa - avatar