New update is available. Click here to update.

Last Updated: 28 Jan, 2021

Difficulty: Hard

```
Do not print anything, just return the number of set bits in the binary representation of all integers between 1 and ‘N’.
```

```
The first line of input contains an integer ‘T’ denoting the number of test cases to run.
Then the next ‘T’ lines represent the ‘T’ test cases.
The first line of each test case contains a single integer ‘N’.
```

```
For each test case, return an integer that is equal to the count of set bits in all integers from 1 to n modulo 1e9+7.
Output for each test case will be printed in a new line.
```

```
You do not need to print anything; it has already been taken care of. Just implement the given function.
```

```
1 <= T <= 100
1 <= N <= 10^9
Time limit: 1 second
```

SIMILAR PROBLEMS

Detect Odd

Posted: 15 Apr, 2022

Difficulty: Moderate

Detect Odd

Posted: 15 Apr, 2022

Difficulty: Moderate

Ninja And The Clan

Posted: 17 Apr, 2022

Difficulty: Moderate

Check whether K-th bit is set or not

Posted: 20 May, 2022

Difficulty: Easy

Check whether K-th bit is set or not

Posted: 20 May, 2022

Difficulty: Easy

Maximum Element

Posted: 21 Jul, 2022

Difficulty: Moderate

XOR DARE

Posted: 3 Sep, 2022

Difficulty: Moderate

Popular Interview Problems: