<s>[INST] For which $n$ is $n\sigma(n)\equiv 2 \pmod {\phi(n)}$? How to find all of $n \in \Bbb N$ such that: $$n\sigma(n)\equiv 2 \pmod {\phi(n)}$$
$\sigma(n)$ is summation of all distinct divisors of $n$
For $p$ prime we have: $p(p+1)=p^2+p\equiv 2 \pmod {p-1}$
but how to prove for composite number : $4,6,22$ is only solution.
 [/INST] Note that $d \mid \phi(n)$ implies that $n\sigma(n) \equiv 2 \pmod{d}$.
If $p^2 \mid n$ for some odd prime $p$, then $p \mid \phi(n)$. Thus $0 \equiv n\sigma(n) \equiv 2 \pmod{p}$, a contradiction. Thus $p^2 \nmid n$ for any odd prime $p$.
If $8 \mid n$, then $4 \mid \phi(n)$. Thus $0 \equiv n\sigma(n) \equiv 2 \pmod{4}$, a contradiction. Thus $8 \nmid n$.
If $4 \|n$, then write $n=4m$, where $m$ is odd. If $m>1$, then $2 \mid \phi(m)$ so $4 \mid 2\phi(m)=\phi(n)$. Thus $0 \equiv n\sigma(n) \equiv 2 \pmod{4}$, a contradiction. Therefore $m=1$, so $n=4$, which is a solution.
Otherwise $n$ is squarefree. 
If $pq \mid n$ for distinct odd primes $p, q$, then write $n=pqm, \gcd(m, pq)=1$. Then $\sigma(n)=\sigma(pq)\sigma(m)=(p+1)(q+1)m$, and $\phi(n)=\phi(n)=\phi(pq)\phi(m)=(p-1)(q-1)\phi(m)$. Thus $4 \mid \sigma(n), \phi(n)$, so $0 \equiv n\sigma(n) \equiv 2 \pmod{4}$, a contradiction. 
Therefore we have $n=1, 2, p$ or $2p$, where $p$ is an odd prime. If $n=1, 2$, then $\phi(n)=1$, so we trivially have $n\sigma(n) \equiv 2 \pmod{1}$. If $n=p$, then $\phi(p)=p-1, \sigma(p)=p+1$, so $p\sigma(p)=p(p+1) \equiv 2 \pmod{p-1}$. Therefore $n=1, 2, p$ are solutions.
Suppose that $n=2p$. Then $\phi(n)=p-1$ and $\sigma(n)=1+2+p+2p=3(p+1)$. Then we have $2 \equiv 2p\sigma(p)=6p(p+1) \equiv 12 \pmod{p-1}$, so $(p-1) \mid 10$. Since $p$ is an odd prime, we get $p=3, 11$. This gives $n=6, 22$, which are indeed solutions.
Therefore all solutions are given by $n=1, 4, 6, 22$ and $n=p$, $p$ prime.
</s>