Write a program that does the following:
Run 1,000,000 trials of the following:
- Generate two random integers, each between 1 and Integer.MAX_VALUE, inclusive.
- Find the GCF (Greatest Common Factor) of the two random integers.
- Keep count of how many times the two random integers were coprime (GCF of 1).
Print the proportion of trials where the two random integers were coprime.
Then print a "magic number" which is the square root of (6 / the above proportion).
Run the program 10 times and write down your results each time (both the proportion and the "magic number").
Turn in your code and your results.
Questions:
What do you think the magic number is an estimate of?
Based on that, what is the exact theoretical probability of two random positive integers being coprime?