rank and nullity of a matrix 
Let $A=[a_{ij}]$ be the $n \times n$ matrix with
  $$
 a_{ij} =
 \begin{cases}
  1 & \text{if $i+j$ is even}, \\
  0 & \text{if $i+j$ is odd}.
 \end{cases}
$$
  Find the rank and nullity of $A$ for every $n$.

I worked out for $n = 3$ that $\mathrm{rank}(A) = 2$ and $\mathrm{nullity}(A) = 1$, but is there a general formula? 
Also, I am stuck on the second part of the question:

Let $B = [b_{ij}]$ be the $(2n+1) \times (2n+1)$ matrix such that every entry of $B$ is $0$ except for the two main diagonals, where all the elements are equal to $1$, i.e
  $$
 b_{ij} =
 \begin{cases}
  1 & \text{if $i = j$}, \\
  1 & \text{if $i+j = 2N+2$},\\
  0 & \text{otherwise}.
 \end{cases}
$$
  Find the rank and nullity of the matrix B for every $n$.

Again, is there a set formula for this?
 A: Without checking explicitly, I'm pretty sure that $A$ is just simply a "checkerboard" of $1$'s and $0$'s.
Something like:
$$\begin{bmatrix}\color{red}{1}&0&\color{red}{1}&0&\color{red}{1}&0&\color{red}{1}&0&\color{red}{1}\\
0&\color{red}{1}&0&\color{red}{1}&0&\color{red}{1}&0&\color{red}{1}&0\\
\color{red}{1}&0&\color{red}{1}&0&\color{red}{1}&0&\color{red}{1}&0&\color{red}{1}\\
0&\color{red}{1}&0&\color{red}{1}&0&\color{red}{1}&0&\color{red}{1}&0\\\color{red}{1}&0&\color{red}{1}&0&\color{red}{1}&0&\color{red}{1}&0&\color{red}{1}\\
0&\color{red}{1}&0&\color{red}{1}&0&\color{red}{1}&0&\color{red}{1}&0\\\color{red}{1}&0&\color{red}{1}&0&\color{red}{1}&0&\color{red}{1}&0&\color{red}{1}\\
0&\color{red}{1}&0&\color{red}{1}&0&\color{red}{1}&0&\color{red}{1}&0\\\color{red}{1}&0&\color{red}{1}&0&\color{red}{1}&0&\color{red}{1}&0&\color{red}{1}\\
\end{bmatrix}$$
Are the columns of $A$ related somehow?

They repeat.  Every odd column is $[1,0,1,0,\dots]$ while every even column is $[0,1,0,1,\dots]$

How many linearly independent columns can you find?

 only two

What does that imply about the rank?

 one of the many interpretations/equivalent definitions of rank is the most number of linearly independent columns you can find in a matrix, so $rank(A)=2$ for all $n$ other than $n=1$ since the same argument applies regardless which value $n$ was.  The exception being $n=1$, in which case $A=\left[\begin{smallmatrix}1\end{smallmatrix}\right]$ and so $rank(A)=1$.

What does that imply about the nullity?  

 by the rank-nullity theorem, $n=rank(A)+nullity(A)$ so $nullity(A)=n-rank(A)=n-2$.  The exception being when $n=1$ in which case $nullity(A)=0$


Approach similarly for $B$, how many linearly independent columns can you find?
A: The matrix $B$ is, for $n=1$,
$$
\begin{bmatrix}
1 & 0 & 1 \\
0 & 1 & 0 \\
1 & 0 & 1
\end{bmatrix}
$$
and, for $n=2$,
$$
\begin{bmatrix}
1 & 0 & 0 & 0 & 1 \\
0 & 1 & 0 & 1 & 0 \\
0 & 0 & 1 & 0 & 0 \\
0 & 1 & 0 & 1 & 0 \\
1 & 0 & 0 & 0 & 1 \\
\end{bmatrix}
$$
and you can observe that the $(n+1)\times(n+1)$ upper left corner is the identity matrix. So the rank is at least $n+1$. Can it be larger?
