What does number of setbits really tell about number..?

bitmask count set bits 2

Total number of factors of n

Total number of divisors of n

Total number of unset bits in binary representation of a n

Total number of set bits in binary representation of a n

bitmask count set bits
bool get (int n)
{
    int x = 0;
    while( n )
    {
        x += n&1;
        n = n>>1;
    }
    return x;
}

Above function will return :-

Choices
  • Total number of divisors of n
  • Total number of factors of n
  • Total number of unset bits in binary representation of a n
  • Total number of set bits in binary representation of a n

this is complete question and ans is

  • Total number of set bits in binary representation of a n