Dividing an integer into a fixed number of integers What is the formula for dividing an integer into a fixed number of integers where the greatest distance between consecutive integers is 1.
Dividing 10 into 4 integers we can get:
[3, 3, 2, 2]

Dividing 7 into 4 integers we can get:
[2, 2, 2, 1]

Dividing 10 into 8 integers we can get:
[2, 2, 1, 1, 1, 1, 1, 1]


Allowing fractions, you would split exactly as
$$\left[\frac{10}4,\frac{10}4,\frac{10}4,\frac{10}4\right].$$
Adding those fractions from left to right, you get
$$\left[\frac{10}4,\frac{20}4,\frac{30}4,\frac{40}4\right].$$
Then taking the integer parts,
$$[2,5,7,10].$$
And finally the pairwise differences
$$[2,3,2,3].$$
Other examples,
$$\left[\frac74, \frac74,\frac74,\frac74\right]\to\left[\frac74, \frac{14}4,\frac{21}4,\frac{28}4\right]\\
\to[1,3,5,7]\to[1,2,2,2].$$
$$\left[\frac{10}8,\frac{10}8,\frac{10}8,\frac{10}8,\frac{10}8,\frac{10}8,\frac{10}8,\frac{10}8\right]\to\left[\frac{10}8,\frac{20}8,\frac{30}8,\frac{40}8,\frac{50}8,\frac{60}8,\frac{70}8,\frac{80}8\right]\\
\to[1,2,3,5,6,7,8,10]\to[1,1,1,2,1,1,1,2].$$
This doesn't just give you the numbers, but a permutation that minimizes the cumulated error.
Algebraically, the numbers are
$$\left\lfloor\frac{n(i+1)}m\right\rfloor-\left\lfloor\frac{ni}m\right\rfloor.$$
They are in close relation with the Bresenham's line drawing algorithm that draws on oblique line on a square grid.

Note that by the definition of integer division,
$$m=qn+r=q(n-r)+(q+1)r$$ where $q=\lfloor n/m\rfloor$ is the integer quotient and $r=m\bmod n$ the remainder, such that $0\le r<n$. So among the $n$ numbers, $n-r$ of them equal $q$ and $r$ equal $q+1$.
