Find rank of $A$ Let $A$ be the following $n\times n$ matrix
$$A = \begin{pmatrix} 1 &k&k\\ k&1&k\\ k&k&1
\end{pmatrix}$$
(Not sure how to format, so I just typed in a $3\times 3$ matrix here).
What is the rank of $k$?
Obviously if $k=1$ then $\text{rank}(A)=1$. What happens when $k\ne 1$? I suspect that the rank is $n$. I tried to show that dimension of the kernel is zero, but did not succeed. I also thought about rewriting $A$ as something like
$$A = k\begin{pmatrix} 1&1&1\\ 1&1&1\\ 1&1&1
\end{pmatrix}+(1-k)\begin{pmatrix}1&0&0\\0&1&0\\0&0&1\end{pmatrix}=kB+(1-k)I$$
I see that rank of $I$ is 3, given that $k\ne 1$, and rank of $B$ is 1. But I don't know how I should related that back to matrix $A$? Because I don't think $\text{rank}(A+B)=\text{rank}(A) + \text{rank}(B)$ is true in general.
update: I also tried to consider the $2\times 2$ matrix. The characteristic polynomial is just $(1-\lambda)^2 - k^2=0$. This gives us two roots: $1+k$ and $1-k$. Thus, $A$ will be similar to the following matrix $A'$:
\begin{pmatrix} 1+k&0\\0&1-k\end{pmatrix}
If $\text{rank}(A') = \text{rank}(A)$ is true, then the result follows. The only difficult part then is to find the eigenvalue for a general $n\times n$ matrix.
 A: $A$ is singular iff its determinant is $0$. 
$$
det A = 1.(1-k^2) -k (k - k^2) +k (k^2 - k) = 2k^3 - 3k^2 + 1
$$
We know $k=1$ is a solution so factor it out
$$
2k^3 - 3k^2 + 1 = (k-1)(2k^2 - k - 1)
$$
$(k-1)$ is also a factor of the quadratic, so we complete the factorisation
$$ 
det A = (k-1)^2 (2k+1)
$$
For $k=-1/2$ we obtain the matrix 
$$
\left( \begin{array}{ccc}
1 & -1/2 & -1/2 \\
-1/2 & 1 & -1/2 \\
-1/2 & -1/2 & 1 \end{array} \right)
$$
This has rank $2$. Each row is $-1$ * (sum of the other two rows). Rather neat!
A: One can prove by induction that either $k=1$ and the rank is $1$ or $k=-\frac{1}{n-1}$ and the rank is $n-1$ otherwise the rank is $n$. Assume this is true for the $n$ square matrix. Now consider an $n+1$ square matrix and let $r$ be smallest such that the first $r$ rows and linearly dependent. If $r\leq n$ then the left upper square of size $r$ has rank $<r$ and so by induction $k=-\frac{1}{r-1}$ and the linear relation is that the sum of the first $r$ rows is zero. A contradiction as this relation does not hold in coordinates larger than $r$. Thus $r=n+1$. Now observe that the given value of $k$ gives a linear relation, which must be unique by minimality of $r$. 
