Playing with Bits time limit

Hi @rhythm9
You are getting time limit because you are using same variable that is i in both for and while loop and every time you are calculating number of set bits in i you are reducing it to 0 and then for loop increments that i to 1 and hence your loop keeps on going without termination.

I have changed your code a little bit have a look :

Thanx ALot Aayush!! got it now