A number $x_n$ of the form 10101...1 has $n$ ones. Find all $n$ such that $x_n$ is prime.
1. Consider the number \( x_n \) which is of the form \( 10101\ldots1 \) with \( n \) ones. This number can be expressed as:
   \[
   x_n = \frac{10^{2n} - 1}{99}
   \]
   This is because the number \( 10101\ldots1 \) with \( n \) ones can be written as a geometric series:
   \[
   x_n = 1 + 10^2 + 10^4 + \cdots + 10^{2(n-1)}
   \]
   The sum of this geometric series is:
   \[
   x_n = \frac{10^{2n} - 1}{10^2 - 1} = \frac{10^{2n} - 1}{99}
   \]

2. To determine when \( x_n \) is prime, we need to analyze the factors of \( \frac{10^{2n} - 1}{99} \). Notice that:
   \[
   10^{2n} - 1 = (10^n - 1)(10^n + 1)
   \]
   Therefore:
   \[
   x_n = \frac{(10^n - 1)(10^n + 1)}{99}
   \]

3. For \( n > 2 \), both \( 10^n - 1 \) and \( 10^n + 1 \) are greater than 99. This implies that \( x_n \) is not prime because it can be factored into two non-trivial factors.

4. We need to check the cases for \( n = 1 \) and \( n = 2 \):
   - For \( n = 1 \):
     \[
     x_1 = \frac{10^2 - 1}{99} = \frac{100 - 1}{99} = \frac{99}{99} = 1
     \]
     1 is not a prime number.
   - For \( n = 2 \):
     \[
     x_2 = \frac{10^4 - 1}{99} = \frac{10000 - 1}{99} = \frac{9999}{99} = 101
     \]
     101 is a prime number.

5. Therefore, the only value of \( n \) for which \( x_n \) is prime is \( n = 2 \).

\(\blacksquare\)

The final answer is \( \boxed{ n = 2 } \)