随机数 不用Math.random()

知乎链接

var rand = (function(){
  var today = new Date(); 
  var seed = today.getTime();
  function rnd(){
    seed = ( seed * 9301 + 49297 ) % 233280;
    return seed / ( 233280.0 );
  };
  return function rand(number){
    return Math.ceil(rnd(seed) * number);
  };
})();

console.log(rand(50))

你可能感兴趣的:(随机数 不用Math.random())