Rank of an NxN matrix This question very similar to this one.
I have this problem I'm working on. I think I have it figured out but I just want to make sure I am not misunderstanding how rank works.
The question goes like this, 
Consider an nXn matrix where the elements go from 1 to $ n^2 $ as you read across and then down.  For instance a 3X3 matrix where n = 3 looks like this:
$ \left( \begin{array}_
1 & 2 & 3 \\
4 & 5 & 6 \\
7 & 8 & 9 \end{array} \right)$ 
What is the rank of the nXn matrix, as a function of n, for n>=2?
Drawing out the matrices for n=2 to n=5 I can spot a pretty obvious pattern in the matrix construction and the whole thing can be written in terms of n:
$ \left( \begin{array}_
1 & 2 & 3 & ... & n  \\
n+1 & n+2 & n+3 & ... & 2n  \\
2n+1 & 2n+2 & 2n+3 & ... & 3n  \\
3n+1 & 3n+2 & 3n+3 & ... & 4n  \\
... &... &... & ... & ... \\
n^2-n+1  & n^2-n+2 & n^2-n+3 & ... & n^2 \end{array} \right)$  
From this I can spot that as soon as you get past the 3rd row, you can sum the prior rows to cancel out that row. 
For instance take row 4 from above for the first column.
If I take $ row 3 + row 2 - row 1 $ I get this value 
$ (2n+1) + (n+1) - (1) = 3n+1 $
Which is the next rows value in row 4. 
And that can be carried out on the rest of the columns to produce the same result. 
So for any arbitrary row k beyond row 3, I can make that row all zeros by doing a row reduction of: 
Rk -> Rk - Rk-1 - Rk-2 + Rk-3
Thus the maximum rank this matrix can have is 3 correct? 
Is this a reasonable way to solve this problem or there a more direct approach I should be taking? 
 A: Subtracting the first row from the others we obtain $n-1$ rows multiple  of $(n,n,\ldots,n)$ therefore $\operatorname{rank}(A)=2$ for any $n\ge 2$.
A: Your approach is fine for this problem but sometimes it is very hard to see the pattern between rows or columns. 
So a general way of finding the rank of the matrix is by reducing it to it's Row Echelon Form (note that row-reduced echelon form is not necessary). You just have to make all the elements zero below the pivot elements. So you have:
$$ \left[ \begin{array}_
1 & 2 & 3 \\
4 & 5 & 6 \\
7 & 8 & 9 \end{array} \right]\xrightarrow[R_3=R_3-7R_1]{R_2=R_2-4R_1} \left[ \begin{array}_
1 &\ \ \ 2 &\ \ \ 3 \\
0 &-3 &-6 \\
0 &-6 &-12 \end{array} \right] \xrightarrow[]{R_3=R_3-2R_2} \left[ \begin{array}_
1 &\ \ \ 2 &\ \ \ 3 \\
0 &-3 &-6 \\
0 &\ \ \ 0 &\ \ \ 0 \end{array} \right]$$
After reducing it you just have to count the number of  non-zero rows and that's your rank. Here as you can see it's $2$. This can help you find the rank of any matrix.
