Tap here to switch tabs
Problem
Submissions

Problem: Prime Number of Set Bits in Binary Representation

med
30 min
Try to solve the Prime Number of Set Bits in Binary Representation problem.

Statement

Given two integers left and right, return the total count of numbers in the inclusive range [[left, right]] that have a prime number of set bits in their binary representation.

Recall that the number of set bits is the total count of 11’s present in the binary representation of an integer.

Constraints:

  • 1≤1 \le left ≤\le right ≤106\le 10^6

  • 0≤0 \le right −- left ≤104\le 10^4

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Prime Number of Set Bits in Binary Representation

med
30 min
Try to solve the Prime Number of Set Bits in Binary Representation problem.

Statement

Given two integers left and right, return the total count of numbers in the inclusive range [[left, right]] that have a prime number of set bits in their binary representation.

Recall that the number of set bits is the total count of 11’s present in the binary representation of an integer.

Constraints:

  • 1≤1 \le left ≤\le right ≤106\le 10^6

  • 0≤0 \le right −- left ≤104\le 10^4