Count Set Bits
In a binary number, you only see zeroes and ones, and sometimes you need to count the positions that are switched on. The function egg_count receives display_value and returns the number of 1 bits in its binary representation. For example, if the binary form contains four ones, the result should be 4.
Примеры
Ввод
0Вывод
0Ввод
16Вывод
1Ввод
89Вывод
4Нужно реализовать
def egg_count(display_value: int) -> int:
Теги
math
Inicia sesión para ver tu historial de envíos
Iniciar sesiónInicia sesión para usar el AI Mentor
Iniciar sesiónVisible tests
1
Input
0Expected
02
Input
16Expected
13
Input
89Expected
44
Input
2000000000Expected
135
Input
255Expected
86
Input
999999Expected
12Focus radio
Paused · SomaFM · Fluid