Find all $n$ s.t. $nσ(n) ≡ 2 \pmod{\varphi(n)}$ This question from CMI Mathematics Exam
Category C Practice Paper
October 14, 2018, subjective questions, 3rd problem.

Find all natural numbers such that
  $$nσ(n) ≡ 2 \pmod{\varphi(n)}$$
  where:
  $φ(n)$ is the Euler’s Totitent Function, $σ(n)$ is the sum of positive divisors of n

I could not find a solution to this problem. Any hint on how to find a solution to this problem, thanks in advance.
 A: As stated in Euler's totient function, you have
$$\varphi(n) = n\prod_{p\mid n}\left(1 - \frac{1}{p}\right) = n\prod_{p\mid n}\left( \frac{p - 1}{p}\right) \tag{1}\label{eq1A}$$
You require
$$nσ(n) ≡ 2 \pmod{\varphi(n)} \implies \varphi(n) \mid nσ(n) - 2 \tag{2}\label{eq2A}$$
If there's any odd prime factor $p$ of $n$ with a multiplicity $\gt 1$, then \eqref{eq1A} shows $p \mid \varphi(n)$. Along with $p \mid n$, \eqref{eq2A} shows $p \mid 2$, which is not possible.
Next, consider the factors of $2$. If there's $3$ or more factors of $2$, then $4 \mid \varphi(n)$ and $4 \mid n$, which is not possible. If there's $2$ factors of $2$, along with at least one odd prime factor, then once again you have $4 \mid \varphi(n)$ and $4 \mid n$, which is not possible. Thus, apart from $n = 4$, which does work, you can have at most one factor of $2$.
This shows that, apart from $n = 4$, all possible solutions are square-free. Thus, as indicated at Divisor function, you have for all those other cases that
$$\sigma(n) = \prod_{p\mid n}(1 + p) \tag{3}\label{eq3A}$$
If you have $2$ or more unique odd prime factors, since each odd prime factor contributes at least one factor of $2$ to $\sigma(n)$, this shows that $4 \mid \sigma(n)$. Also, \eqref{eq1A} shows that $4 \mid \varphi(n)$. However, as explained earlier, this is not possible.
As such, there is at most one odd prime factor of $n$, say $p$. First, consider $n$ has no factor of $2$, so $n = p$. You thus have $\varphi(n) = p - 1$ and $\sigma(n) = p + 1$. Thus, $nσ(n) - 2 = p(p + 1) - 2 = (p - 1)(p + 2)$, so \eqref{eq2A} holds.
Next, consider $n = 2p$. You have $\varphi(n) = p - 1$ and $n\sigma(n) = 2p(3(p + 1)) = 6p(p + 1)$. For \eqref{eq2A} to hold requires that
$$\begin{equation}\begin{aligned}
6p(p + 1) - 2 \equiv 0 \pmod{p - 1} \\
6(2) - 2 \equiv 0 \pmod{p - 1} \\
10 \equiv 0 \pmod{p - 1} \\
\end{aligned}\end{equation}\tag{4}\label{eq4A}$$
Thus, this requires $p - 1$ is $1$, $2$, $5$ or $10$. For odd primes $p$, this is only the case for $p = 3$ and $p = 11$, giving that $n = 6$ and $n = 22$ also work.
As $n = 1$ also works, the summary of all of the solutions are $1 \le n \le 7$, $n = p$ for all primes $p \gt 7$, and $n = 22$.
A: Let $$n = p_1^{\alpha_1}\ldots p_r^{\alpha_r} $$ 
be the unique prime factorisation of $n$, where 
$p_1 < \cdots < p_r$ are primes and $\alpha_1, \ldots, \alpha_r$ are natural numbers. 
Then 
$$ \sigma(n) = \prod_{j=1}^r \frac{ p_j^{\alpha_j + 1} - 1 }{ p_j - 1} $$
and
$$ \phi(n) = n \prod_{j=1}^r \left( 1 - \frac{1}{p_j} \right). $$
Now 
$$ n \sigma(n) \cong 2 (\mod \phi(n) ) $$
iff
$$ \phi(n) \, \vert \, \big( n \sigma(n) -2 \big). $$
Hope this helps.
