>_
count_bits.php
PHP 8.5
Not run yet

+ 6 hidden

Input
n = 7
Expected
[0, 1, 1, 2, 1, 2, 2, 3]

7 is 111 in binary, three 1 bits, the most of any number up to 7. 6 is 110 and 5 is 101, two each.