/*
为何使用Math.floor()
Math.round()
[0, 0.5] 之间的值返回0
[0.5, 1.4] 之间的值返回1
[1.5, 2.4] 之间的值返回2
etc.
这导致0出现的可能性减半
Math.floor()
[0, 0.9] 返回0
[1, 1.9] 返回1
[2, 2.9] 返回2
etc.
max-min+1, 补上floor 掉的1
*/
Math.floor(Math.random() * (max - min + 1) + min);
/*
探索为何与Math.random() 相乘也能平均的获取随机数?
Math.random() 会平均得到0.0001 这样小的数
0.0001 * 75 → 0.0075, 可以看到还是非常小, 几乎等于0
Math.random() 会平均得到0.9999 这样大的数
0.9999 * 75 -> 74.9925, 可以看到最大也不超过75
所以乘以n 会得到0~n 之间的随机数
探索是否包含min 与max
min = 16, max = 28
Math.floor(Math.random() * (max - min + 1) + min);
Math.random() * (28 - 16 + 1)
0.001 * 13 → 0.013
Math.floor(0.013 + 16) → 16 → 可以看到包含min
0.999 * 13 → 12.987
Math.floor(12.987 + 16) → 28 → 可以看到包含max
*/
Math.random() 不包括0 和 1
参考