How many right angled isosceles triangles with Perimeter=n can be drawn for $n<2017$ This problem concerns triangles which have vertices with integer coordinates
in the usual x, y-coordinate plane. For how many positive
integers n < 2017 is it possible to draw a right-angled isosceles triangle
such that exactly n points on its perimeter, including all three of its
vertices, have integer coordinates?
What I've done:
$P=n, n \in N $ (P being the permieter)
$i^2=l^2+l^2$ (Pythagora's applied on the isosceles triangle)
$i=l \sqrt2$
$P=2l+l \sqrt2$
$P=l(2+ \sqrt2)$
And because $P \in N$
$l=(2- \sqrt2)u, u \in N$ (so that $l$ is a multiple of $2-\sqrt2$ )
So I got this:
$l=u(2- \sqrt2)$
$i=2u(\sqrt2-1)$
$P=u(2\sqrt2-2+4-2\sqrt2)=2u=n$
Since $u=\{1,2,3,4,...,2016\}$:
$n=\{2,4,6,...,2016\}$
So there are $1008$ values of n that satisfies the conditions(which is the correct answer).
There's one thing I'm not sure how to prove though. That for all these $n$s and $u$s the vertices of the triangles have integer coordinates. Could I have some hints on how to do that? Thank you. 
 A: Here $n$ integer points on does not necessarily mean that the perimeter should be $n$ (consider a triangle formed by $(0,0),(0,1),(1,0)$. The perimeter of this triangle is $2+\sqrt{2}$, but it contains exactly $3$ points on its perimeter).
Since two of the segments of the right isosceles triangle meets with a right angle, one of the segments should have a slope whose absolute value is less than or equal to $1$. For the case which the value is $1$, we see that the triangle is somewhat like $(0,0), (-k, k), (k,k)$ for $k\in\mathbb{N}$, which is easy to see that perimeter contains $4k$ integer coordinates.
Except for that case, by moving the triangle (parallel to x-axis or y-axis) and rotating by taking some vertex as a center, one can see that the triangles can be generalized as having vertices $(0,0), (qk, pk), ((q-p)k, (p+q)k)$ for $p, q, k\in\mathbb{N}, \gcd(p,q)=1, p<q$. Or, one can show that any right isosceles triangle with vertices having integer coordinates is congruent to one of those triangles, and it has the same number of integer coordinates on its perimeter.
Now all left is to count number of integer coordinates on the triangle. First we have $(0,0), (qk,pk), ((q-p)k, (p+q)k)$. Between $(0,0)$ and $(qk,pk)$ we have $k-1$ points, and also $k-1$ points between $(qk,pk)$ and $((q-p)k, (p+q)k)$.
Since $\gcd(q-p, q+p)=1$ or $2$, between $(0,0)$ and $((q-p)k, (p+q)k)$ we can have either $k-1$ points $(q-p, p+q), \cdots, ((q-p)(k-1), (p+q)(k-1))$ or $2k-1$ points $(\frac{q-p}{2}, \frac{p+q}{2}), \cdots, (\frac{q-p}{2}(2k-1), \frac{p+q}{2}(2k-1))$. Summing up these leads to either $3k$ points or $4k$ points, so the answer is all positive integer less than $2017$ which is a multiple of $3$ or $4$. 
