In order the positive integer n to have exactly 6 positive divisors, it must be of the form n2−9=q5 or n2−9=p2q, where p, q are primes mutually different.
In the first case we have n2−9=q5⇒(n−3)(n+3)=q5 (1)
It gives that
n−3=qs and n+3=qt, with t>s and t+s=5.
By subtracting we get qt−qs=6⇔qs(qt−s−1)=2⋅3 and hence q∈{2,3}.
For q=2 (1) gives n2=41, (it has no solutions in Z), while for q=3, (1) gives n2=252, (impossible in Z).
In the second case n2−9=p2q, it follows that (n−3)(n+3)=p2q, and so
(n+3=pq and n−3=p) or (n+3=q and n−3=p2)or (n+3=p2 and n−3=q).
From the first case we get p(q−1)=6, and hence (p=3 and q=3), which must be rejected because p=q.
From the last two cases we conclude that gcd(n−3,n+3)=1.