+ 1

Why isn't it working. The answer should be 3.

https://code.sololearn.com/cL3OOn3trya6/?ref=app

21st Nov 2018, 5:51 PM
ariel
ariel - avatar
5 Respuestas
+ 1
Great it's work. Didn't notice that. Thanks for help everyone especially Julien Quentin
21st Nov 2018, 8:10 PM
ariel
ariel - avatar
0
But there is a "break" in the "if" so if the 'd' int will be equal to the 'a' int so it should break the while loop else it should keep looping till the if condition will be right.
21st Nov 2018, 6:15 PM
ariel
ariel - avatar
0
And why is that?
21st Nov 2018, 6:29 PM
ariel
ariel - avatar
0
The problem is that “d” will never be equal to “a”. Values of “d” are: 1, 1, 1, 2, 4, 8, 24, 72, 216, 864, 3456, ... //keeps increasing infinitely Nome of these values equals 81.
21st Nov 2018, 6:37 PM
Diego
Diego - avatar
0
As I can see this the program do next: d =1 three Times then the it adding 1 to c so now c equal 2 than d = 4,8,16 then it's adding again because the if is false again so now it go again while loop for loop but now the c is 3 so d= 9,27,81. end of the for loop. now the if is true do the break and print the c=3
21st Nov 2018, 6:53 PM
ariel
ariel - avatar