Compute number of 2s in a range of (0...n)