linear algebra (matrices) - challenging problem (determination of method/algorithm) I wonder about the following method/algortithm about square matrices $A_{n \times n}$ $\in$ $M_{n\times n}(\mathbb{K})$, where $\mathbb{K} $ $\in$ {$ \mathbb{R}, \mathbb{C}$ }.
Given certain value of determinant, propose method of constructing square matrix of any possible dimension with as least 0's as matrix's terms as possible.
In other words, let me give example:
I have determinant, let say, equal to 5. In what way could I construct matrix of arbitrary dimension (e.g. of dimension 6 x 6)?
To sum up, I wonder about method/algorithm, which enables to construct any square matrix associated with given determinant such that this matrix has as least 0's terms as possible.
By method/algorithm, I mean deterministic procedure, not a guess.
Any help very appreciated! 
 A: Let $A=(a_{ij})_{1\leq i\leq j}$ where $$a_{ij}=\left\lbrace\begin{array}{lcl}1 &\text{if} & i\neq j & \text{or} & i=j=1\\2 &\text{if} & 1<i= j<n,  \\ x+1 &\text{if} & i= j=n,  \\\end{array}\right.$$ 
Then you can check that the determinant of $A$ is exactly $x$. For example, when $n=5$, $A$ is
$$
A=\left(\begin{array}{ccccc} 
1 & 1 & 1 & 1 & 1 \\
1 & 2 & 1 & 1 & 1 \\
1 & 1 & 2 & 1 & 1 \\
1 & 1 & 1 & 2 & 1 \\
1 & 1 & 1 & 1 & x+1 \\
\end{array}\right)
$$
As noted by user1551, when $x=-1$ we have the problem that $x+1$ becomes zero ; in this case, simply take the matrix for $x=1$ and interchange any two columns or rows in it. 
A: Here's something similar to Ewan's except it may be more transparent for some.
Firstly if you want $\det=0$ take the matrix of all $1$'s, except of course in the $1\times1$ case.
Then for $\det\neq 0$ take the diagonal matrix 
$D=(d_{ij})_{1\leq i,\,j\leq n}$ where $$d_{ij}=\begin{cases}
 0 &\text{if} & i\neq j \\
 1 &\text{if} & i=j \text{ and } i\neq n  \\ 
x &\text{if} & i=n,  \\\end{cases}$$ 
so then D pretty much looks like this:
$$
D=\left(\begin{array}{ccccc} 
1 & 0 & 0 & \ldots & 0  \\
0 & 1 & 0 & \ldots & 0 \\
0 & 0 & 1 & \ldots & 0 \\
\vdots & \vdots & \vdots & \vdots & \vdots \\
0 & 0 & 0 & 0 & x \\
\end{array}\right)
$$
It is clear then that $\det(D)=x$. Now adding and subtracting rows doesn't change the determinant so first, add every row (barring itself) to the $1^{st}$ row to give:
$$
D'=\left(\begin{array}{ccccc} 
1 & 1 & 1 & \ldots & x  \\
0 & 1 & 0 & \ldots & 0 \\
0 & 0 & 1 & \ldots & 0 \\
\vdots & \vdots & \vdots & \vdots & \vdots \\
0 & 0 & 0 & 0 & x \\
\end{array}\right)
$$
Then finally add the first row to every other row;
$$
D''=\left(\begin{array}{ccccc} 
1 & 1 & 1 & \ldots & x  \\
1 & 2 & 1 & \ldots & x \\
1 & 1 & 2 & \ldots & x \\
\vdots & \vdots & \vdots & \vdots & \vdots \\
1 & 1 & 1 & 1 & 2x \\
\end{array}\right)
$$
So $\det(D'')=x$, and since this is for $x\neq 0$ none of the entries are zero either.
