Initial commit

This commit is contained in:
2024-03-11 12:43:52 +02:00
parent 0cc291f3d8
commit a57340adb7
55 changed files with 2961 additions and 1 deletions

18
JavaScript/code_cycle.js Normal file
View File

@@ -0,0 +1,18 @@
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));

View File

@@ -0,0 +1,28 @@
const total_attempts = 15000000;
var successful_attempts = 0;
var get_random = () => {
return Math.floor(Math.random() * 256);
}
for (var i = 0; i < total_attempts; i++)
{
/*
var a = Math.floor(Math.random() * 256);
var b = Math.floor(Math.random() * 256);
var c = Math.floor(Math.random() * 256);
*/
var a = get_random();
var b = get_random();
var c = get_random();
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));