Basic-benchmark-experiment/TypeScript/code_cycle.js

14 lines
440 B
JavaScript
Raw Normal View History

2024-03-11 12:43:52 +02:00
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));