chapter  4
14 Pages

## Random Numbers

In this chapter we discuss the generation random numbers in C++. The motivation is the problem introduced in Section 3.1: let pn be the probability that two numbers, sampled independently and uniformly from {1,2, . . . ,n} are relatively prime. What can we say about pn as n→ ∞? In Chapter 3 we used direct enumeration to calculate pn for various values of n.

However, as n approaches 100,000, the time for the computer to complete the calculation becomes excessive. This motivates us to find another attack. The approach we take is to sample pairs of integers in {1,2, . . . ,n} at random and keep track of how often we find that they are relatively prime. To do this, however, we require a mechanism to generate (pseudo) random numbers.