随机数Math.random()公式

1.  0-x之间的随机数:

Math.round(Math.random()*x);

2.  x至y之间的随机数

Math.round(Math.random()*(y-x)+x);

3.  1-x之间的随机数:

Math.ceil(Math.random()*x);

原文地址:https://www.cnblogs.com/sese/p/6396818.html