What is the probability of selecting a prime number when picking a random number between 1 and 100?

Instruction: Choose an integer uniformly from 1 through 100 inclusive. Find the probability it is prime, explain a method to verify the prime count, and generalize the expression to 1 through N.

Context: This question evaluates the candidate's knowledge of prime numbers and their ability to calculate probability over a defined range.

Updated

Official answer

There are 25 primes among the 100 integers 1 through 100, so the probability is 25/100 = 1/4 = 25%.

The primes are 2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97. The number 1 is not prime; 2 is the only even prime.

A reproducible counting method is the sieve of Eratosthenes: begin with integers 2 through 100, then mark multiples of each unmarked prime starting at its square. Only primes through sqrt(100) = 10 need to mark multiples, because a composite number at most 100 has a prime factor at most 10.

Follow-up: For uniform integers 1 through N, the exact probability is the count of primes at mostN divided byN. For nonuniform sampling, sum the selection probabilities of the prime values instead.

Assessment: Define the sampling domain, exclude 1 and justify the count; a list alone does not demonstrate a general counting method.

Related Questions