14 lines
440 B
JavaScript
14 lines
440 B
JavaScript
|
var total_attempts = 256 * 256 * 256;
|
||
|
var successful_attempts = 0;
|
||
|
for (var a = 0; a < 256; a++) {
|
||
|
for (var b = 0; b < 256; b++) {
|
||
|
for (var c = 0; c < 256; c++) {
|
||
|
if (a + b + c > 300)
|
||
|
successful_attempts++;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
console.log("Iterations: " + total_attempts);
|
||
|
console.log("Successful checks: " + successful_attempts);
|
||
|
console.log("Probability: " + (successful_attempts / total_attempts));
|