# Let the rational number $p/q$ be closest to but not equal to $22/7$ among all rational numbers with denominator $< 100$.

Let the rational number $$p/q$$ be closest to but not equal to $$22/7$$ among all rational numbers with denominator $$< 100$$. What is the value of $$p − 3q$$ ?

My approach: $$22/7=3.14$$, therefore, $$p/q=314/100$$ but according to the question p/q has a denominator that's less than $$100$$ satisfying which $$p/q$$ can be $$157/50$$. But the given closest value is $$22/7$$. Hence I concluded that $$p/q=313/100$$ which gave me the answer as $$13$$. However, the answer key says it's $$14$$. Where am I going wrong? Is it because I'm taking it up to $$2$$ decimal places?

• I don’t know any techniques for finding the CLOSEST, other than writing a computer program to check all p/q with q<100, but since $22/7 \approx 3.142857$, I can see that $3.141414...$ would be a closer approximation than $3.13$, so that would be $3 \frac{14}{99} = \frac{311}{99}$, which gives $p-3q=14$. – Joe Sep 14 at 11:19

$$\left|\frac pq-\frac{22}7\right|=\left|\frac{7p-22q}{7q}\right|$$

The point is to solve the Diophantine equation $$7p-22q=\pm1$$ and get the greatest possible value for $$q$$.

It turns out that $$7\cdot 311-22\cdot99=-1$$, so your fraction is $$\frac{311}{99}$$

• It turns out because $7p-22q=\pm1$ implies $q \equiv \pm 1 \bmod 7$ and the largest such $q$ less than $100$ is $99$. – lhf Sep 14 at 11:09

$${22 \over 7} = 3 + {1 \over 7}$$

Previous convergent before reaching $${22 \over 7}$$ is $${3 \over 1}$$

To produce a "semi-convergent" close to but not equal $${22 \over 7}$$

$${22k ± 3 \over 7k ± 1}$$

$$d = max(7k ± 1) < 100 = 7\times14+2$$

Closest fraction = $$\large {22\times14\;+\;3 \over 7\times14\;+\;1} = {311 \over 99}$$