If I select two integers at random, what is the probability that their sum will be prime?
import sympy import random n = 1 m = 100000000 N_ITER = 10000000 n_sum_primes = 0 n_single_primes = 0 for i in range( N_ITER ): p1 = random.randint( n, m ) p2 = random.randint( n, m ) if( sympy.isprime( p1 ) ) : n_single_primes += 1 if( sympy.isprime( p1 + p2 ) ) : n_sum_primes += 1 print( n_sum_primes / N_ITER ) print( n_single_primes / N_ITER )
This is not right, because you've wrongly assumed that the limiting case is a valid probability distribution. Which it is not.The probability to pick a prime out of all integers is zero.
Indeed. Which means that we cannot properly pose the question about primes in the naturals as a question about probability.The correct answer is that there is no uniform distribution on the integers.
He said randomly selected integers, not positive integers.I would think that the probability that the sum of a pair of randomly selected integers between and is prime would be a little smaller than the probability that an integer selected randomly between and will be prime
The larger the random number is, the more likely that it has a divisor and that becomes practically certain in the limit. Furthermore, picking a natural number "at random" out of all the natural numbers implies that the picked number would tend to be HUGE. There is no limit to how huge.
To get a non-zero answer, we would have to limit the allowable selection to a finite subset.
My post was just meant to be intuitive. I am not knowledgeable enough to give a formal proof. The others on this thread are more qualified to answer.
Mine, too. Yes, there is no probability distribution and maybe we should have said likelihood instead of probability, or - as I did - relative frequency, or density of primes. And yes, the probability of picking one prime as opposed to a prime as a sum of finitely many integers from a finite set of integers may be slightly different, or not. Fact is, it doesn't matter.My post was just meant to be intuitive. I am not knowledgeable enough to give a formal proof. The others on this thread are more qualified to answer.
You only need generate one random number.If I select two integers at random, what is the probability that their sum will be prime?
I think you mean the prime counting function? The RZF is something else.You only need generate one random number.
The Riemann zeta function approximates the number of primes less than a given magnitude.
Select one random integer, evaluate the derivative of the RZF for that value, and you have the probability that a value of that magnitude will be prime.
(2,3,5),(-2,-3,5),(2,-3,-5) and (-2,3,-5) can also be considered as prime factors. Up to units means that units can be arbitrarily distributed.The unique prime factors of -30 are; ( 2, 3, -5 ) or ( 2, -3, 5 ) or ( -2, 3, 5 ) or ( -2, -3, -5 ).
I guess all four must be the unique factors.