#### Topic: Prompt with the decision of task LeetCode

Given a nonnegative integer number num. For every number i in the range 0 <= i <= num calculate the number of 1's in their binary representation and return them as an array.

Example:

For num = 5 you should return [0,1,1,2,1,2].

The standard decision of the task:

```
int [] bits = new int [num + 1];
for (int i = 1; i <= num; i ++) {
bits [i] = bits [i>> 1] + (i AND 1);
}
return bits;
```

Question: why "i>> 1"? We do shift in the right and as though bits look how many was in the previous digit?

But after all then it would be possible to do simply bits [i - 1] and it is stupid to take previous...

With "i&1" it is clear, it signals us that in the end of current number costs 1 or 0 and here it is necessary to increase/not to increase the counter