当前位置:网站首页>JS generate random numbers
JS generate random numbers
2022-07-02 03:24:00 【onYang】
const getNum = (andNum, Num) => {
//andNum Sum of random numbers ,Num Number of random numbers
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)
边栏推荐
- 焱融看 | 混合雲時代下,如何制定多雲策略
- Gradle 笔记
- One of the future trends of SAP ui5: embrace typescript
- Use blocking or non blocking for streamline
- Work hard all day long and be alert at sunset
- Kotlin基础学习 17
- Grpc quick practice
- Kotlin基础学习 16
- Merge interval, linked list, array
- Global and Chinese market of X-ray detectors 2022-2028: Research Report on technology, participants, trends, market size and share
猜你喜欢
知物由学 | 自监督学习助力内容风控效果提升
Start a business
[C Advanced] brother Peng takes you to play with strings and memory functions
Verilog 避免 Latch
JIT deep analysis
Force deduction daily question 540 A single element in an ordered array
《MATLAB 神经网络43个案例分析》:第41章 定制神经网络的实现——神经网络的个性化建模与仿真
Verilog 状态机
Discrimination between sap Hana, s/4hana and SAP BTP
ThreadLocal详解
随机推荐
js生成随机数
Comment élaborer une stratégie nuageuse à l'ère des nuages mixtes
PMP personal sprint preparation experience
小米青年工程师,本来只是去打个酱油
焱融看 | 混合云时代下,如何制定多云策略
SAML2.0 notes (I)
Verilog reg register, vector, integer, real, time register
Possible causes of runtime error
C#联合halcon脱离halcon环境以及各种报错解决经历
Verilog timing control
知物由学 | 自监督学习助力内容风控效果提升
[C Advanced] brother Peng takes you to play with strings and memory functions
[golang] leetcode intermediate bracket generation & Full Permutation
跟着CTF-wiki学pwn——ret2shellcode
流线线使用阻塞还是非阻塞
The capacity is upgraded again, and the new 256gb large capacity specification of Lexar rexa 2000x memory card is added
Yan Rong looks at how to formulate a multi cloud strategy in the era of hybrid cloud
Global and Chinese market of autotransfusion bags 2022-2028: Research Report on technology, participants, trends, market size and share
Verilog 避免 Latch
Verilog 线型wire 种类