Computing determinant of a matrix with non-zero values on three diagonals let $A$ be an $n\times n$ matrix with entries $a_{ij}$ such that
$a_{ij}=2$ if $i=j$.
$a_{ij}=1$ if $|i-j|=2$
and $a_{ij}=0$ otherwise.
compute the determinant of $A$.
using the famous formula $\det A=\sum_{i=1}^{n}(-1)^{i+j}a_{ij}\det A^{(ij)}$ where $A{(ij)}$ is the submatrix obtaining from $A$ by omiting it's $i$th row and $j$th colomn, I reached to the formula $\det A=\frac{1}{4}n^2+n+\frac{7}{8}+\frac{1}{8}(-1)^n$. is it correct?

If $A$ is of this form
$$A_{7\times 7}=
\begin{pmatrix}
     2   &  0   &  1  &   0  &   0  &   0  &   0 \\
     0   &  2   &  0  &   1  &   0  &   0  &   0 \\ 
     1   &  0   &  2  &   0  &   1  &   0  &   0 \\ 
     0   &  1   &  0  &   2  &   0  &   1  &   0 \\ 
     0   &  0   &  1  &   0  &   2  &   0  &   1 \\ 
     0   &  0   &  0  &   1  &   0  &   2  &   0 \\ 
     0   &  0   &  0  &   0  &   1  &   0  &   2 \\ 
\end{pmatrix},
$$
I get 
$$
\det(A) = 
\begin{cases}
\frac{n^2}{4}+n+1,\quad n \text{  even}\\
\quad\\
\frac{n^2}{4}+n+\frac{3}{4},\quad n  \text{  odd}
\end{cases}
$$
This is just an alternative way of stating the questioner's own succint answer:
$$\det(A) = \frac{n^2}{4}+n+\frac{7}{8} +(-1)^n\frac{1}{8}.$$
This is a nice exercise in symbolic $LU=A$ factorization and would be a good exam question to separate the good from the mediocre students. 
