 What's up guys? My name is Michael and welcome to my YouTube channel. Today we are going to do another problem called will it ever stop on espadge. Basically Bob has this code and you're just asking will it ever stop and this is the code while n is greater than 1. If n mod 2 is equal to 0 then we divide it by 2 else we multiply by 3 and add by 3 help him find it out soon. Okay, so this is actually not that difficult. If you just plug in a bunch of numbers you'll actually see the pattern of this problem. So basically if it's a power of 2, right, if it's a power 2, so here you're just basically checking if it's a power 2, right? Because here if we had like if n is equal to 8 it's going to divide 8 by 2 which gets you 4. And then because 4 is even if n mod 2 is equal to 0 this checks if it's even. If n mod 2 is equal to 0 that checks if it's even. Then 4 divided by 2 is 2 and then after the loop again 2 divided by 2 is 1 so then this would stop. So it would only stop when it's a power of 2, right? Because if it's not a power of 2, let's say it was like, I don't know, let's say it was, I don't know, 18 or something. Wait, is that a power 2? Yeah, 18. Let's say it was 18. 18 is even, right? So we divide by 2 which gets you 9. Then this L statement is going to make it 9 times 3 gets you 27 plus 3 gets you 30. And that's going to increase the number of n to become 30. And then you get 30 divided by 2 is 15 and then because it's still not a power 2, right? It's going to do 3 times 15 gets you 45 plus 3 will get you 48. So yeah, the loop would just never end at that point. It would just never stop, right? So all you have to do is just based on this code is just check if it's a power 2 or not. And if it is, then you just print out tack if it is otherwise print out nie. And here's how you check if it's a power 2. So here I read in the number n that we're doing in this code, right? And I just check, I take the log base of 2 and gets me this long value. Then I just check if the power of 2 to this long value of my answer is equal to n. Then that's a power of 2, right? No, we know it's a power 2. Then we print out tack. Otherwise we print out nie. And the reason why this works is because let's say you have 16, right? So if I take the log base of 2 of 16, it'll get me 4. So then this is the same thing as doing 2 to the 4 is equal to 16, right? So I'm checking. So after when I take log base 2 of 16, I get 4. And what I'm doing is I'm taking 2 and I raising it to a power of 4 to get me and I'm checking if it's equal to 16. So if it's equal to the original number that we had before after taking log base 2 of it and then raising it again, then it is a power of 2. Otherwise it's not a power of 2. So yeah, that's pretty much it. That's pretty much the gist of the question. Hope you guys enjoyed this short video. Rate, comp, subscribe. I'll check you guys later. Peace.