Solution:
We say that a positive integer is good if it has the given property. Let n be a good number, and let d1,d2,…,dk be the divisors of n in the circle, in that order. Then for all 1≤i≤k, di+1/di (taking the indices modulo k) is equal to either pi or 1/pi for some prime pi. In other words, di+1/di=piϵi, where ϵi∈{1,−1}. Then
p1ϵ1p2ϵ2⋯pkϵk=d1d2⋅d2d3⋯dkd1=1
For the product p1ϵ1p2ϵ2⋯pkϵk to equal 1, any prime factor p must be paired with a factor of 1/p, and vice versa, so k (the number of divisors of n) must be even. Hence, n cannot be a perfect square.
Furthermore, n cannot be the power of a prime (including a prime itself), because 1 always is a divisor of n, and if n is a power of a prime, then the only divisor that can go next to 1 is the prime itself.
Now, let n=paqb, where p and q are distinct primes, and a is odd. We write the divisors of n in a grid as follows: In the first row, write the numbers 1,q,q2,…,qb. In the next row, write the numbers p,pq,pq2,…,pqb, and so on. The number of rows in the grid, a+1, is even. Note that if two squares are adjacent vertically or horizontally, then their corresponding numbers are prime-related. We start with the square with a 1 in the upper-left corner. We then move right along the first row, move down along the last column, move left along the last row, then zig-zag row by row, passing through every square, until we land on the square with a p. The following diagram gives the path for a=3 and b=5:

Thus, we can write the divisors encountered on this path in a circle, so n=paqb is good.
Next, assume that n is a good number. Let d1,d2,…,dk be the divisors of n in the circle, in that order. Let p be a prime that does not divide n. We claim that n⋅pe is also a good number. We arrange the divisors of n⋅pe that are not divisors of n in a grid as follows:
d1pd2p⋮dkpd1p2d2p2⋮dkp2……⋱…d1ped2pe⋮dkpe
Note that if two squares are adjacent vertically or horizontally, then their corresponding numbers are prime-related. Also, k (the number of rows) is the number of factors of n, which must be even (since n is good). Hence, we can use the same path described above, which starts at d1p and ends at d2p. Since d1 and d2 are adjacent divisors in the circle for n, we can insert all the divisors in the grid above between d1 and d2, to obtain a circle for n⋅pe.
Finally, let n be a positive integer that is neither a perfect square nor a power of a prime. Let the prime factorization of n be
n=p1e1p2e2⋯ptet
Since n is not the power of a prime, t≥2. Also, since n is not a perfect square, at least one exponent ei is odd. Without loss of generality, assume that e1 is odd. Then from our work above, p1e1p2e2 is good, so p1e1p2e2p3e3 is good, and so on, until n=p1e1p2e2⋯ptet is good.
Therefore, a positive integer n has the given property if and only if it is neither a perfect square nor a power of a prime.