Basic-benchmark-experiment/C/code_cycle.c

28 lines
569 B
C
Raw Permalink Normal View History

2024-03-11 12:43:52 +02:00
#include <stdio.h>
int main()
{
int iterations = 256*256*256;
int successes_amount = 0;
for (int a = 0; a < 256; a++)
{
for (int b = 0; b < 256; b++)
{
for (int c = 0; c < 256; c++)
{
if (a + b + c > 300)
{
successes_amount++;
}
}
}
}
printf("Iterations: %d\n", iterations);
printf("Valid sums: %d\n", successes_amount);
printf("Probability: %f\n", (float) successes_amount / iterations);
return 0;
}