1
2
3
4
5
6
7
def
bits_set
(
n
):
i
=
0
while
n
:
if
n
&
1
:
yield
i
i
+=
1
n
>>=
1