Generates m-bit random numbers based on time, maximum 13-bit random numbers, and does not guarantee that the first number is not 0
Function Ran (m) {
m = m > 13:m;
var num = new Date (). GetTime ();
Return num.tostring (). substring (13-m);
}
Console.log (Ran (5));
According to the random function generated by the math of the random number intercept m, the maximum number of random numbers not more than 16, to ensure that the first is not 0
function rand (m) {
m = m > 16:m;
var num = Math.random (). toString ();
if (Num.substr (num.length-m, 1) = = ' 0 ') {return
rand (m);
}
Return num.substring (NUM.LENGTH-M);
}
Console.log (rand (5));
Based on the random function of math, there is no limit to the number of digits, first not 0
function Rando (m) {
var = ';
for (var i = 0; i < m i++) {
var val = parseint (Math.random () *10);
if (i = = 0 && val = = 0) {
i--;
Continue;
}
num + = val;
}
return num;
}
Console.log (Rando (5));