84669 person learning
152542 person learning
20005 person learning
5487 person learning
7821 person learning
359900 person learning
3350 person learning
180660 person learning
48569 person learning
18603 person learning
40936 person learning
1549 person learning
1183 person learning
32909 person learning
100 yuan is given to 10 people in red envelopes. The size of the red envelope is random and everyone can get a red envelope
rpAmount = 100 ppCount = 10 rpResult=[] rpRnds = [] rpRndSum = 0 for(let i=0;i<ppCount;i++){let rnd = Math.random();rpRndSum+=rnd;rpRnds.push(rnd);} rpRnds.forEach((rnd)=>{rpResult.push(rpAmount*rnd/rpRndSum)}) console.log('rpResult',{rpResult,sum:rpResult.reduce((acc,val)=>{return acc+val})})
Core idea:The weight is directly determined by the random number, not the amount.
You can take a look at this/q/10...
Idea: Use the random function to randomly allocate each time. The red envelope value obtained each time is greater than 0.01 and less than the remaining amount - the remaining number of people * 0.01. The last person can get all the remaining money
Core idea:
The weight is directly determined by the random number, not the amount.
You can take a look at this
/q/10...
Idea: Use the random function to randomly allocate each time. The red envelope value obtained each time is greater than 0.01 and less than the remaining amount - the remaining number of people * 0.01. The last person can get all the remaining money