const getNum = (andNum, Num) => {
//andNum随机数之和,Num随机数个数
var randomNum = new Array()
let sum = 0
for (var i=0;i<Num-1;i++)
{
x = Math.floor(Math.random() * (andNum - sum))
randomNum[i] = x
sum += x
}
randomNum[Num-1] = andNum - sum
return randomNum
}
getNum(50,6)
12-23
7083
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)