Tap here to switch tabs
Problem
Submissions

Problem: Prime Number of Set Bits in Binary Representation

Prime Number of Set Bits in Binary Representation asks you to count integers in a given inclusive range whose binary forms contain a prime number of ones.

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

Prime Number of Set Bits in Binary Representation asks you to count integers in a given inclusive range whose binary forms contain a prime number of ones.

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