TITLE: Problem on divisibility.
QUESTION [5 upvotes]: Find all natural numbers $n\geq1$ such that $n^2$ does not divide $(n-2)!$.
I tried to do it by supposing prime factorization of n in terms of variable, but I cannot buzz it, please help!

REPLY [2 votes]: Well the key really lies in prime factorization. 
Suppose $n = pqr,$ where $p < q$ are primes and $r > 1$. Then $p ≥ 2, q ≥ 3$ and $ r ≥2$ ,not necessarily a prime. Thus we have $n−2 ≥ n−p=pqr−p≥5p>p$, 
$n−2 ≥ n−q=q(pr−1)≥3q>q$, 
$n−2 ≥ n−pr=pr(q−1)≥2pr>pr$,
 $n−2 ≥ n−qr=qr(p−1)≥qr$. 
Observe that $p,q,pr,qr$ are all distinct. Hence their product divides $(n − 2)!$. Thus $n^2 = p^2q^2r^2 $divides $(n −2)!$ in this case. We conclude that either $n = pq$ where $p,q$ are distinct primes or $n = pk$ for some prime $p$. 
Case 1.
Suppose $n = pq $ for some primes $p,q,$ where $2 < p < q$. Then $p ≥ 3$ and $q ≥ 5$. In this case $n−2 > n−p=p(q−1)≥4p$, 
$n−2 > n−q=q(p−1)≥2q$. 
Thus $p,q,2p,2q$ are all distinct numbers in the set ${1,2,3,... ,n − 2}.$ 
We see that $n^2 = p^2q^2$ divides $(n − 2)!$. 
We conclude that $n = 2q$ for some prime $q ≥ 3$. Note that $n−2=2q−2<2q$ in this case so that $n^2$ does not divide $(n−2)!$. 
Case 2.
 Suppose $n = pk$ for some prime $p$. We observe that $p,2p,3p,...(pk−1 −1)p$ all lie in the set ${1,2,3,... ,n −2}$. If $pk−1 −1 ≥ 2k,$ then there are at least $2k$ multiples of $p$ in the set ${1,2,3,... ,n − 2}.$ Hence $n^2 = p^2k$ divides $(n−2)!.$ Thus $pk−1 −1 < 2k.$ If $k ≥ 5$, then $pk−1 −1 ≥ 2k−1 −1 ≥ 2k$, which may be proved by an easy induction. Hence $k ≤ 4.$ If $k = 1$, we get $n = p,$ a prime. If $k = 2,$ then $p−1 < 4$ so that $p = 2 \ or \ 3$; we get $n = 22 ,4 \ or $ $ n = 32 , 9$ . For $k = 3$, we have $p^2 −1 < 6$ giving $p = 2$; $n =23,8$ in this case. Finally, $k = 4$ gives $p^3 −1 < 8$. Again $p = 2 $ and $ n = 24 , 16$. However $n^2 = 28$ divides $14!$ and hence is not a solution. Thus $n = p,2p$ for some prime $p$ or $n = 8,9$.
The answer would have been more interesting and less lengthy had op given some extra conditions. But nevertheless, question was beautiful.