Find all $n$ with exactly $8$ divisors (counting $1$ and $n$ itself), the sum of which is equal to $684$. Find all $n$ with exactly $8$ divisors (counting $1$ and $n$ itself), the sum﻿ of which is equal to $684$.


I've written down two formulas from there https://en.wikipedia.org/wiki/Divisor_function?wprov=sfla1 and got stuck.
The possible numbers are as follows where $p,q,r$ are distinct primes:

$p^7$ where $\frac{p^8-1}{p-1}=684$ NO SOLUTIONS

$p^3q$ where $\frac{p^4-1}{p-1}(q+1)=684$ NO SOLUTIONS

$pqr$ where $(p+1)(q+1)(r+1)=684$ THE ONLY SOLUTION IS 2.5.37=370
For $n$ to have eight divisors, it must be of the form (all variables standing for different primes)
$$p^7,\quad p^3q,\quad\text{or}\quad pqr $$
(because $8=4\cdot 2=2\cdot 2\cdot 2$ ar all ways to write $8$ as product).
The sums of divisors then are
$$ p^7+p^6+p^5+p^4+p^3+p^2+p+1,\quad (p^3+p^2+p+1)(q+1),\quad (p+1)(q+1)(r+1),$$
respectively, and shall equal $684$.

In the first variant, $p=2$ leads to an odd sum, whereas already for $p=3$, the sum is $&gt;684$. So this case  can be excluded.

In the second variant, from $q\ge 2$ we get the bound $p&lt;\sqrt[3]{\frac{684}3}\approx 6.1$, so $p\le 5$. Then $p^3+p^2+p+1$ is one of $15$, $40$, $156$. None of these divides $684$, so this case  can be excluded as well.

In the third variant, we may assume wlog. that $p&gt;q&gt;r$. Note that $8\nmid 684$, so one of the three factors must be odd, $r=2$. Then the other factors are necessarily even and we arrive at $\frac{p+1}2\frac{q+1}2=3^2\cdot 19$, so either $\frac{p+1}2=19$, $\frac{q+1}2=9$, or $\frac{p+1}2=57$, $\frac{q+1}2=3$, or $\frac{p+1}2=171$, $\frac{q+1}2=1$. In other words,
$p=39$, $q=19$, or $p=115$, $q=7$, or $p=343$, $q=3$. As none of the candidates for $p4 is prime, we again fid no solution.