Pergunta de entrevista da empresa Apple

Count the switched on bits of a given binary number.