19 lines
402 B
TypeScript
19 lines
402 B
TypeScript
|
const 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));
|