<s>[INST] Determinant of matrix $[a_{ij}]$ where $a_{ij}=ij$ if $i\ne j$ and $a_{ij}=1+ij$ if $i=j$ Let $A=[a_{ij}]$ be a square matrix of order $n$ whose entries are given as follows. 
For $1\leq i,j\leq n$ we have $a_{ij}=ij$ if $i\neq j$ and $a_{ij}=1+ij$ if $i=j$.
I have to evaluate the determinant.
I just wrote the matrix but don't know how to proceed further.
 [/INST] Let the determinant be $D_n$. Then 
$$
D_n = \det 
\begin{bmatrix} 
1 + 1^2 & 1 \times 2 & 1\times 3 & \cdots & 1\times n\\
2\times 1 & 1 + 2^2 & 2\times 3 & \cdots & 2 \times n \\
3\times 1 &  3 \times 2 & 1 + 3^2 & \cdots & 3 \times n \\
\vdots & \vdots &\vdots & \ddots & \vdots\\
n\times 1 & n \times 2 & n\times 3 & \cdots & 1 + n^2
\end{bmatrix} =
\det 
\begin{bmatrix} 
1 + 1^2 & 1 \times 2 & 1\times 3 & \cdots & 0\\
2\times 1 & 1 + 2^2 & 2\times 3 & \cdots & 0 \\
3\times 1 &  3 \times 2 & 1 + 3^2 & \cdots & 0\\
\vdots & \vdots &\vdots & \ddots & \vdots\\
n\times 1 & n \times 2 & n\times 3 & \cdots & 1
\end{bmatrix} +\det
\begin{bmatrix} 
1 + 1^2 & 1 \times 2 & 1\times 3 & \cdots & 1\times n\\
2\times 1 & 1 + 2^2 & 2\times 3 & \cdots & 2 \times n \\
3\times 1 &  3 \times 2 & 1 + 3^2 & \cdots & 3 \times n \\
\vdots & \vdots &\vdots & \ddots & \vdots\\
n\times 1 & n \times 2 & n\times 3 & \cdots &  n^2
\end{bmatrix} = D_{n-1} + n \det
\begin{bmatrix} 
1 + 1^2 & 1 \times 2 & 1\times 3 & \cdots & 1\\
2\times 1 & 1 + 2^2 & 2\times 3 & \cdots & 2  \\
3\times 1 &  3 \times 2 & 1 + 3^2 & \cdots & 3  \\
\vdots & \vdots &\vdots & \ddots & \vdots\\
n\times 1 & n \times 2 & n\times 3 & \cdots & n
\end{bmatrix} = D_{n-1} + n \det
\begin{bmatrix} 
1 & 0& 0& \cdots & 1\\
0 & 1 &0 & \cdots & 2  \\
0& 0 & 1 & \cdots & 3  \\
\vdots & \vdots &\vdots & \ddots & \vdots\\
0&0&0 & \cdots & n
\end{bmatrix} = D_{n-1} + n^2,
$$
i.e. 
$$
D_n = D_{n-1} + n^2. 
$$
Therefore
$$
D_n = D_2 + (3^2 + 4^2 + \dots + n^2) = 1 + (1^2+2^2 + \cdots + n^2) = 1 + \frac {n(n+1)(2n+1)}6. 
$$
Another trial
preparation
$\newcommand \bm \boldsymbol  $
$ \newcommand \trans {^{\mathsf T}}$

For $$\bm A\in \mathrm M_m, \bm D \in  \mathrm M_n, \bm B \in \mathrm M_{m,n}, \bm C \in \mathrm M_{n,m},$$ let $\bm M$ be a block matrix
  $$
\bm M = \begin {bmatrix}
\bm A & \bm B \\ \bm C & \bm D
\end{bmatrix}, 
$$
  1. if $\bm A$ is invertible, then $$\det \bm M = \det \bm A \det (\bm D - \bm C\bm A^{-1}\bm B); $$
  2. if $\bm D$ is invertible, then $$\det \bm M = \det \bm D \det (\bm A - \bm B\bm D^{-1}\bm C); $$
  3. Specifically when both $\bm A, \bm D$ are invertible, 
  $$
\det \bm D \det (\bm A - \bm B\bm D^{-1}\bm C)= \det \bm A \det (\bm D - \bm C\bm A^{-1}\bm B). 
$$
Proof. 1. Take the determinant on the equation
  $$
\begin{bmatrix} \bm I_m & \bm O\\ -\bm C\bm A^{-1} & \bm I_n \end{bmatrix}\bm M = \begin{bmatrix}\bm A & \bm B \\ \bm O & \bm D - \bm C\bm A^{-1} \bm B \end{bmatrix}.
$$
  2. Similar argument.  3. Put 1, 2 together. 

Now for the question. Let that matrix be $\bm A$. Then $$\bm A - \bm I_n = [jk]_{n \times n} = \bm c\bm c \trans $$ where $$
\bm c = \begin{bmatrix} 1 & 2 &  3 & \cdots & n\end{bmatrix}\trans. 
$$
So by the formula we mentioned, 
$$
\det \bm A =- \det (-\bm I_1)\det (\bm I_n - \bm c (-\bm I_1)^{-1} \bm c \trans) \stackrel {\bigstar}=  -\det (\bm I_n) \det (-\bm I_1 - \bm c \trans \bm I_n^{-1} \bm c) = 1 + \bm {c}\trans \bm c = 1 + (1^2 + 2^2 + \cdots + n^2) = 1 + \frac {n (n+1)(2n+1)}6. 
$$
</s>