class Solution(object):
    def countBits(self, num):
        alist=[]
        for i in range(num+1):
            n=0
            import math
            while math.pow(2,n)<num:
                n+=1
            count=0
            for j in range(n,-1,-1):
                if i>=math.pow(2,j):
                   i-=math.pow(2,j)
                   count+=1
            alist.append(count)
        return alist