For positive rational $x$, if $x$ is written in the form $p/q$ with $p, q$ positive relatively prime integers, define $f(x)=p+q$. For example, $f(1)=2$.

a) Prove that if $f(x)=f(mx/n)$ for rational $x$ and positive integers $m, n$, then $f(x)$ divides $|m-n|$.

b) Let $n$ be a positive integer. If all $x$ which satisfy $f(x)=f(2^nx)$ also satisfy $f(x)=2^n-1$, find all possible values of $n$.

[i]Anderson Wang.[/i]
### Part (a)
1. Let \( x = \frac{a}{b} \) with \(\gcd(a, b) = 1\).
2. We want to show that \( f\left(\frac{ma}{nb}\right) = f(x) \). By definition, \( f(x) = a + b \).
3. Write \( f\left(\frac{ma}{nb}\right) = \frac{ma + nb}{\gcd(ma, nb)} \).
4. Since \(\gcd(a, b) = 1\) and \(\gcd(m, n) = 1\), we have \(\gcd(ma, nb) = \gcd(a, n) \cdot \gcd(b, m)\).
5. Therefore, \( f\left(\frac{ma}{nb}\right) = \frac{ma + nb}{\gcd(a, n) \cdot \gcd(b, m)} \).
6. Given \( f(x) = f\left(\frac{ma}{nb}\right) \), we have:
   \[
   a + b = \frac{ma + nb}{\gcd(a, n) \cdot \gcd(b, m)}
   \]
7. This implies:
   \[
   (a + b) \cdot \gcd(a, n) \cdot \gcd(b, m) = ma + nb
   \]
8. Rearrange to get:
   \[
   n(a + b) + (m - n)a = (a + b) \cdot \gcd(a, n) \cdot \gcd(b, m)
   \]
9. Since \(\gcd(a + b, a) = \gcd(b, a) = 1\), it follows that \(a + b\) divides \(m - n\).

Thus, \( f(x) \) divides \( |m - n| \).

### Part (b)
1. Suppose \( f(x) = f(2^n x) \). Then:
   \[
   a + b = \frac{2^n a + b}{\gcd(2^n a, b)}
   \]
2. For \( f(2^n x) \leq f(x) \), we need \( 2 \mid b \). Let \( v_2(b) = k \) where \( k < n \).
3. Then:
   \[
   f(2^n x) = \frac{2^n a + b}{2^k} = 2^{n - k} a + \frac{b}{2^k} = a + b
   \]
4. This implies:
   \[
   (2^n - 2^k) a = b (2^k - 1)
   \]
5. Since \(\gcd(a, b) = 1\), we have:
   \[
   2^n - 2^k = bz \quad \text{and} \quad 2^k - 1 = az \quad \text{for some integer } z
   \]
6. Therefore:
   \[
   a + b = \frac{2^n - 1}{z}
   \]
7. The condition holds if and only if we cannot find \( k \) such that \(\gcd(2^{n - k} - 1, 2^k - 1) > 1\).
8. Note that:
   \[
   \gcd(2^{n - k} - 1, 2^k - 1) = 2^{\gcd(n - k, k)} - 1 = 2^{\gcd(n, k)} - 1
   \]
9. We want \(\gcd(n, k) = 1\) for \(1 \leq k < n\). This holds exactly when \( n \) is prime.

Thus, \( n \) must be a prime number.

The final answer is \( \boxed{ n } \) must be a prime number.