Empresa engajada
Write a function that takes in an integer and returns the number of ones set in the binary representation.
Sigiloso
count = 0 while(num) { num &= num-1; count++; } return count;
I thought the question was asking how to convert the integer to binary code and output it.
function getOnes($int) { return substr_count(decbin($int), '1'); }
__builtin_popcount(num) :D
Fique por dentro de todas as oportunidades e dicas internas seguindo as empresas de seus sonhos.
Comece a buscar vagas para receber atualizações e recomendações personalizadas.