I want to draw this matrix in Latex and this is what I was trying to do but it doesn't work, I don't know how to fix it to make it look like the attached picture.
\documentclass[12pt,a4paper,intlimits,tbtags,reqno]{report}
\usepackage{tabularx}
\begin{document}
\begin{table}[ht]
\centering
\label{my-label}
$A_{n} = \left(
\begin{array}{l|c|c}
2\hspace{2 em}9 & 2
& \\
1\hspace{2 em}2 & 5\hspace{2 em}2 & \\ \cline{1-3}
\hspace{2 em}3 & 7\hspace{2 em}5\hspace{2 em}2& & \\
\hspace{2 em}&3\hspace{2 em}7\hspace{2 em}5\hspace{2 em}2& \\\cline{1-3}
& 3&1\hspace{2 em}9 &\\
& &5\hspace{2 em}4 \\
\end{array}
\right)$
\end{table}
\end{document}
nicematrix
package. If you see the manual, in page 3 you will find an example very similar to your imagetexdoc nicematrix
in a command line or search in ctan. After doing the last one here is the link for the manual ctan.org/pkg/nicematrix