def count_ones(N):
    """
    Count number of ones in a binary representation of a given decimal N
    >>> count_ones(8)
    1
    >>> count_ones(9)
    2
    >>> count_ones(7)
    3
    """

    num = 0

    while(N>0):
        if (N & 1) == 1:
            num += 1
        N = N >> 1
    
    return num