I have a numer = 20. And I want to divide this number into N equals parts or approximate to each other. N maybe from 1 to 20.

I write this code:

```
ArrayList<Integer> c = new ArrayList<>();
int num = 20;
int count = N; //where N some number (from 1 to 20)
int val = (int) Math.floor(num / count);

for (int i = 0; i < count; i++) {
    c.add(val);
}
c.set(0, c.get(0) + num - sum(c));

```

It works fine, for example, when count = N = 3. I get: 8, 6, 6 (8+6+6=20). But if count = N = 12 I get next result: 9, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 (sum = 20). I want that result will be next: 1, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1 (sum = 20). Is that possible?