0

The probability that two integers $m$ and $n$ picked at random are relatively prime is $6/\pi^2$

There is a simple code to check it

n = 10^6;

Count[GCD @@@ RandomInteger[{1, n}, {n, 2}], 1]/n // N

$0.607687$

N[6/Pi^2]

$0.607927$

How can I use CoprimeQ function?

I want to do something like this

 n = 10^6;

Select[RandomInteger[{1, n}, {n, 2}], CoprimeQ]

or

CoprimeQ[#1, #2] &[RandomInteger[{1, n}, {n, 2}]]

but it doesn't work.

vito
  • 8,958
  • 1
  • 25
  • 67

0 Answers0