TITLE: Prove A New Method For Finding Primes.
QUESTION [14 upvotes]: I was recently messing around with harmonic numbers - that is
$H_x = \sum^x_{k=1}\frac{1}{k}$ - and I was thinking what would happen if you applied Gauss' trick to the sum, which is to add up the first and last term, then the second and second-to-last term and so on. This is usually used in adding natural numbers, but when I applied it to the sum I noticed a recurring numerator.
$$\frac{1}{1}+\frac{1}{2}+\frac{1}{3}+\frac{1}{4}+\frac{1}{5}+\frac{1}{6}\to\frac{7}{6}+\frac{7}{10}+\frac{7}{12}$$
I also noticed there were some cases where there wasn't, like $H_{8}$
$$\frac{1}{1}+\frac{1}{2}+\frac{1}{3}+\frac{1}{4}+\frac{1}{5}+\frac{1}{6}+\frac{1}{7}+\frac{1}{8}\to\frac{9}{8}+\frac{9}{14}+\frac{\textbf{1}}{2}+\frac{9}{20}$$
From this I guessed that if $H_x$ with Gauss' trick applied has a constant  numerator, then $x+1$ is prime. I tried proving this, but I'm not sure if I'm right.

Gauss Trick
Harmonic Numbers

REPLY [11 votes]: Notice that if you write $\frac12$ in your second example as $\frac{9}{18}$, then you get your nice pattern back.
Generally each term of your sequence has the form
$$ \frac{1}{n} + \frac{1}{x+1-n} = \frac{x+1}{n(x+1-n)} $$
and if $x+1$ is prime then you can be sure it doesn't reduce further.
On the other hand, if $x+1$ is composite, then there will be at least one of the $n$s that divide it, so in the term for that $n$ both of the numerator and the denominator will be divisible by that $n$, so it can be reduced.
On the other other hand, the term for $n=1$ is $\frac{x+1}{x}$, which never reduces.
So all of the reduced numerators are equal exactly if $x+1$ is prime.

This is hardly a "method for finding primes", though, because computing and reducing all of the sums takes at least as much work as checking whether $x+1$ is prime by trial division anyway.

REPLY [4 votes]: If you consider the $n$-th harmonic number, you add the terms $\frac{1}{k}$ and $\frac{1}{n - k + 1}$. Their sum is
$$\frac{1}{k} + \frac{1}{n - k + 1} = \frac{n - k + 1}{k(n - k + 1)} + \frac{k}{k(n - k + 1)} = \frac{n + 1}{k(n - k + 1)}$$
For $k = 1$ we get $\frac{n + 1}{n}$, which is a fraction in reduced form, since $\gcd(n + 1, n) = 1$. This means that the only possible value for the common numerator is $n + 1$. But this will be the case if and only if $\gcd(n + 1, k) = 1$ and $\gcd(n + 1, n - k + 1) = 1$. For the latter we have
$$\gcd(n, n - k + 1) = \gcd(n + 1, n + 1 - k) = \gcd(n + 1, k).$$
This means that all fractions will be in reduced form if and only if $\gcd(n + 1, k) = 1$ for all $1 \le k \le \lfloor \frac{n}{2}\rfloor$, which is equivalent to $n + 1$ being prime.