+ 1
Why isn't it working. The answer should be 3.
5 Antworten
+ 1
Great it's work. Didn't notice that. Thanks for help everyone especially Julien Quentin
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.
0
And why is that?
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.
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