Tap here to switch tabs
Problem
Submissions

Problem: Count Monobit Integers

Count Monobit Integers asks you to count the values from zero through n whose standard binary representation, without leading zeros, contains only identical bits.

Statement

Given an integer n, return the number of integers in the range [0,‘n‘][0, `n`] that are monobit integers.

An integer is defined as a monobit integer if all the bits in its standard binary representation without leading zeros are identical.

Constraints:

  • 0≤‘n‘≤10000 \leq `n` \leq 1000

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Count Monobit Integers

Count Monobit Integers asks you to count the values from zero through n whose standard binary representation, without leading zeros, contains only identical bits.

Statement

Given an integer n, return the number of integers in the range [0,‘n‘][0, `n`] that are monobit integers.

An integer is defined as a monobit integer if all the bits in its standard binary representation without leading zeros are identical.

Constraints:

  • 0≤‘n‘≤10000 \leq `n` \leq 1000