A number is divided into an array on average.

for example, change a number into an average array
, such as the number 8, and divide it into four times. When it cannot be evenly divided, the value of the first item of the array can be larger than that of the second term, and so on, for example, if it is divided into three parts, it becomes [3p3prit 2], and it is divided into five times.


this is a bit of a handshake. The basic idea is to use this number to evenly divide the number into modular operation and remainder operation. The items in the array are modular values, and then add one to each of the preceding (residual) items.


The

java code is as follows, which should be easy to convert to js

const split = (m, n) => [...Array(m%n).fill(m/n+1|0), ...Array(n-m%n).fill(m/n|0)]
Menu