TITLE: An integer is prime iff $\phi(n) \mid n-1$ and $n+1 \mid \sigma (n)$
QUESTION [15 upvotes]: I wish to prove
An integer is prime iff $\phi(n) | n-1$ and $n+1|\sigma (n)$ where $\phi$ is Euler's totient  function and $\sigma(n)$ is the sum of the positive divisors of n.
I can show from a previous exercise that $\phi(n)|n-1$ implies n is square free.
I also know that $\sigma$ is multiplicative so $\sigma (n)$ is the product of $1+p_i$ for the prime factors of n 
So $\sigma (n) = n+1+S$ where $S$ is a bunch of extra terms which are divisible by $n+1$ since $n+1|n+1$ and $n+1|\sigma(n)$ so $n+1|\sigma (n)-(n+1)$ or $n+1|S$
I suspect that I need to show $n+1|S$ only if n is prime but am not sure how to do so. Or maybe I'm going in the totally wrong direction?
The other part of the proof is trivial since $\phi(p)=p-1$ and $\sigma (p)=p+1$ for any prime $p$ almost directly from the definitions of these functions.

REPLY [2 votes]: This problem is problem number $\textbf{E2611}$ which appeared in the American Math Monthly. I am reproducing the solution below which is due to Paul Vojta. As in Will Fischer's answer it is very clear that $n=p_{1}p_{2}\ldots p_{k}$ where $p_i$ are odd primes for all $i$. This also implies that $$\phi(n)=\prod_{i=1}^{k}(p_{i}-1)\implies 2^{k}\mid\phi(n)$$ Also note that $$\sigma(n)=\prod_{i=1}^{k}(p_i+1)\implies 2^{k}\mid \sigma(n)$$ Our goal is to show $k=1$. If $k\geq 2$ then $4\mid\phi(n)\mid (n-1) \implies 4\nmid n+1$ and this says that the $v_{2}(n+1)=1 \implies 2^{k-1}\mid\frac{\sigma(n)}{n+1}$. This gives us $$2^{k-1} \leq\frac{\sigma(n)}{n+1}<\frac{\sigma(n)}{n}=\prod_{i=1}^{k}\left(1+\frac{1}{p_i}\right)\leq\left(\frac{4}{3}\right)^{k}$$ which fails to hold for $k\geq 2$.