3 ms·
Unless I'm doing something wrong here - just typing some javascript into the console gives me... function rn() { return parseInt(Math.random() * 100);
by ALittleLight 6y ago
Unless I'm doing something wrong here - just typing some javascript into the console gives me...
function rn() {
return parseInt(Math.random() * 100);
}
function drawing(){
let result = [rn(), rn(), rn(), rn(), rn()];
return result.sort();
};
function sequential(arr){
for(let i = 0; i < arr.length-1; i++){
if(arr[i] + 1 != arr[i+1]){
return false
}
}
return true
}
let counter = 0;
for (let i = 0; i < 10000000; i ++){
if (sequential(drawing())){
counter ++;
}
};
console.log(counter);
16
Mathematically, it seems like you'd need to draw one of five numbers from the range, then one of four numbers, then one of three... so the likelihood would be 5/100 * 4/100 * 3/100 * 2/100 * 1/100 = 0.000000012. Although those odds don't seem to line up with the javascript I posted.