I tried to prove above theorem.
I used the Theorem:
Let p be a prime number. Then for any $a,b \in \mathbb{Z}; p|ab \implies p|a$ or $p|b$.
Proof:
Since $n|x^2$, $x^2 = an$.
By prime factorization,
$n = p_1^{t_1}p_2^{t_2}...p_k^{t_k}$ ; $t_1,t_2,...,t_k$ are all odd integers.
$\therefore p_i | n$ for some i $\in \{1,2,...,i\}$
$\therefore p|x^2 \implies p|x$ (Theorem)
Then I can write $x^2=bp_i$ and $x = cp_i$.
$\therefore c^2p_i^2 = bp_i$
$c^2p_i = b$
$\therefore c|b$.
Futher by using $x^2 = an$ and $x^2=bp_i$,
$p_i=\frac{an}{b}$
By substituting this to $x=cp_i$,
$x=\frac{c}{b}.an$
Since $c|b$,
$x=kan$
$\therefore n|x$.(Proved)
Is this proof correct? Is there any better approach or other method?