-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPepysProblem.java
More file actions
43 lines (40 loc) · 1.03 KB
/
PepysProblem.java
File metadata and controls
43 lines (40 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
public class PepysProblem {
public static void main(String[] args) {
//experimenting with 1000 blocks of 6
int wins = 0;
int i = 6;
int j = 10000000;
int play = 0;
int countwins = 0;
while (j > 0) {
while (i > 0) {
play = (int) (Math.random() * 6);
if (play == 1) {countwins++;}
i--;
}
if (countwins >= 1) wins++;
countwins = 0;
i = 6;
j--;
}
System.out.println("Blocks of 6: You got one at least once in " + wins + " experiments.");
//experimenting with 1000 blocks of 12
wins = 0;
i = 12;
j = 10000000;
play = 0;
countwins = 0;
while (j > 0) {
while (i > 0) {
play = (int) (Math.random() * 6);
if (play == 1) {countwins++;}
i--;
}
if (countwins >= 2) wins++;
countwins = 0;
i = 12;
j--;
}
System.out.println("Blocks of 12: You got one at least once in " + wins + " experiments.");
}
}