21 lines
665 B
Java
21 lines
665 B
Java
public class code_cycle {
|
|
public static void main(String[] args) {
|
|
int total_attempts = 256*256*256;
|
|
int successful_attempts = 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) {
|
|
successful_attempts++;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
System.out.println("Iterations: " + total_attempts);
|
|
System.out.println("Valid sums: " + successful_attempts);
|
|
System.out.println("Probability: " + (float) successful_attempts / total_attempts);
|
|
}
|
|
}
|