Consider an $(n+1)\times (n+1)$ grid of lattice points in the plane.
$A(n):$ # of squares with vertices on the grid.
It's relatively well-known that $A(n)=\frac{n(n+1)^2(n+2)}{12}$. Now, $A(n) = B(n) + C(n)$ . Where $B(n) = \frac{n(n+1)(2n+1)}{6}$ is the number of "orthogonal" squares. Meaning that the sides are parallel to borders of original square.
$C(n):$ # of "slanted" squares.
$C(n) = D(n) + E(n)$ . Where,
$D(n):$ # of squares intersecting the sides of unit squares.
$E(n):$ # of squares non-intersecting the sides of unit squares.
My question is to find a closed formula for $E(n)$.
Note that $D(n) + E(n) = \frac{n^4 - n^2}{12}$. Hence $$ D(1) = 0, D(2) = 0, D(3) = 2, D(4) = 10, D(5) = 30, D(6) = 73, D(7) = 148\\ E(1) = 0, E(2) = 1, E(3) = 4, E(4) = 10, E(5) = 20, E(6) = 32, E(7) = 48 $$ Maybe $E(n) = A008050$ in OEIS.
Thanks in advance.