## Total number of set-bits from 1 to n

Given a positive integer n, count the total number of set bits in binary representation of all numbers from 1 to n. Example: Input: n = 3 Output: 4 The way to solve these sorts of problems is to write out the first few values, and look for a pattern [...]