To get the smallest power of two using while loop

In exercise 5, Fix The Broken Code! I can’t understand the while loop here.
How does the code here work to get the smallest power of two?
Why does it use j = j * 2; ? By j = j * 2, doesn’t it mean j times 2? not 2 n, power of two?

Thanks for your explanation in advance.


exponentiation is repeated multiplication, and there you have multiplication in a loop

you might want to carry out the operations yourself in your head/on paper, or add prints to get information out of your program about what happens


Got it now, thank you so much. :grinning: