# 2005 PMWC Problems/Problem T3

## Problem

Replace the letters $a$, $b$, $c$ and $d$ in the following expression with the numbers $1$, $2$, $3$ and $4$, without repetition: $$a+\cfrac{1}{b+\cfrac{1}{c+\cfrac{1}{d}}}$$ Find the difference between the maximum value and the minimum value of the expression.

## Solution

By the greedy algorithm, the maximum value will occur when $a = 4$. To maximize the fraction, we need to minimize the quantity $b + \frac{1}{c + \frac{1}{d}}$, so we need to minimize $b$; $b = 1$. To minimize the remnants, we want to maximize $c + \frac{1}{d}$, so we want to maximize $c = 3$; this leaves $d = 2$.

Following the same pattern of alternating maximums and minimums, the minimum value of the expression occurs when $a = 1, b = 4, c = 2, d = 3$.

Cleaning up the complex fraction, we get $$a + \cfrac{1}{b + \cfrac{d}{cd+1}} = a + \cfrac{cd + 1}{bcd + b + d}$$

Substituting our values gives us that the maximum is $\frac{43}{9}$, while the minimum is $\frac{38}{31}$. Subtracting, our answer is $\frac{991}{279}$.