## If a box contains twenty-one coloured discs, composed of fifteen blue discs and six red discs, and two discs were taken at random, it can be seen that the probability of taking two blue discs, $P(\text{BB}) = (15/21) \times (14/20) = 1/2$.

The next such arrangement, for which there is exactly $50\%$ chance of taking two blue discs at random, is a box containing eighty-five blue discs and thirty-five red discs.

By finding the first arrangement to contain over $10^{12} = 1\,000\,000\,000\,000$ discs in total, determine the number of blue discs that the box would contain.

### The problem raised here is strongly related to the mathematics of continued fractions and Pell’s equation solutions, unlikely to be solved through intuition or trial and error alone.

The problem we’re trying to solve is finding two integers such that their ratio, less an adjustment, equals 1/2:

(Blue / (Blue + Red)) * ((Blue – 1) / (Blue + Red – 1)) = 1/2

With a little rearrangement, this becomes:

2 * Blue * (Blue – 1) = (Blue + Red) * (Blue + Red – 1)

Then, multiply out the brackets and rearrange, the equation is transformed into a Pell’s equation:

2 * Blue^2 – (Blue + Red)^2 + Blue + Red = 0

In order to bring it to the standard form of Pell’s equation, we need to go with:

d * x^2 +/- y^2 = n

Now, we can set x = 2 * Blue + Red, y = Blue + 2 * Red and rearrange:

2 * x^2 – y^2 = n, where n = -1

This is a variation of the standard Pell’s equation, where n is not equal to 1. The solution to this equation forms a sequence of pairs (x, y) and it is a well known that the fundamental pair that generates the remaining solutions can be found as the convergents of sqrt(2).

However, here we’re interested in only positive solutions; the way to find out these pairs starts by expressing sqrt(2) as a continued fraction:

sqrt(2) = [1; 2]

The pattern [1; 2] repeats infinitely and the first few convergents can be seen as the fractions 3/2, 7/5, 17/12, 41/29, 99/70, … and so on.

If we extract the pairs (x, y) from those fractions, we will get the following:

(3, 2), (7, 5), (17, 12), (41, 29)

The solutions to the given problem are obtained from the differences of the two numbers in each pair:

(1, -1), (2, -2), (5, -5), (12, -12), …

This means that the first few pairs (Blue, Red) to our original problem are (1, 1), (3, 2), (15, 6), (85, 35), …

This sequence progresses as an exponential growth, and it won’t be long until the total number of discs exceeds 10^12.

Computing it through a programmatic loop, soon enough we find:

Blue = 756872327473, Red = 313506783024

For which the total number of discs is larger than 10^12. So the box would contain 756,872,327,473 blue discs.

##### More Answers:

Large Non-Mersenne PrimeAnagramic Squares

Largest Exponential