How to write a function to determine the population count of a 16-bit integer using php or javascript. Population count is defined as the number of bits that are "turned on," or in others, it is the number of 1s in a binary representation of a number. For example, the binary number 0b0000 has a population count of 0 because there aren't any 1 bits. 0b0101 has a population count of 2, because 2 bits turned on; 0b1110 has a population count of 3. 0b1111111111111111 has a population count if 16 because there are sixteen 1 bits. Your function should accept an INTEGER argument and return an INTEGER containing its population count. Example:
f (0) = 0
f (1) = 1
f (2) = 1
f (3) = 2
f (4) = 1
f (5) = 2