给出一个整数n,返回一个长度n + 1的数组ans,这样对于每个i (0 <= i <= n),ans[i]是i的二进制表示中的1的数量.在python中写出最短的可能解决方案.
Here's a short solution to the problem in Python:

```
def countBits(n):
    return [bin(i).count('1') for i in range(n+1)]
```

This solution uses a list comprehension to generate the array. For each integer i in the range from 0 to n, the binary representation of i is calculated using the `bin()` function. The `count()` method is then used on this binary string to count the number of 1's in the representation. This count is added to the array being generated. Finally, the complete array is returned.