2026-02-21 15:56:25 +0000 UTC
Prime Number of Set Bits in Binary Representation
Links
Code
class Solution(object):
def countPrimeSetBits(self, L, R):
primes = {2, 3, 5, 7, 11, 13, 17, 19}
return sum(bin(x).count('1') in primes
for x in range(L, R+1))