<s>[INST] Prove that if a rectangle's sides are all odd, then it's diagonal is irrational? In trying to write an alternate and simple proof that at least one leg of a right triangle is a multiple of 4 using Dickson's method of generating triples, I came across quite an interesting observation that ifall the sides of a rectangle is odd, then it's diagonal is irrational. For example, consider a rectangle of length 5 units and breadth 3 units. It's diagonal,by the Pythagorean theorem is 34^0.5, which is irrational. This is the same for lots of rectangles. Is there a general proof for this, or can this whole thing be disproved?
 [/INST] If the sides of the rectangle are integers, then the square of the length of the diagonal is also an integer since 
$d^2 = l^2 + w^2$
and the integers are closed under multiplication and addition.  
The only integers that have rational square square roots are perfect squares.  Since  
$d = \sqrt{l^2 + w^2}$
the length of the diagonal is irrational unless $d^2 = l^2 + w^2$ is a perfect square.
If an integer is a perfect square, then it is either the square of an even number or an odd number.  
If the diagonal is an even number, then $d = 2k$ for some $k \in \mathbb{N}$, so $d^2 = (2k)^2 = 4k^2$.
If the diagonal is an odd number, then $d = 2k - 1$ for some $k \in \mathbb{N}$, so $d^2 = (2k - 1)^2 = 4k^2 - 4k + 1 = 4(k^2 - k) + 1$.
Hence, the square of any integer will have remainder $0$ or $1$ when divided by $4$.
If both the length and width are odd numbers, then $l^2 + w^2$ has remainder $2$ when divided by $4$.  To see this, suppose that $l = 2m - 1$ and $w = 2n - 1$, where $m$ and $n$ are positive integers.  Then
\begin{align*}
d^2 & = l^2 + w^2\\
    & = (2m - 1)^2 + (2n - 1)^2\\
    & = 4m^2 - 4m + 1 + 4n^2 - 4n + 1\\
    & = 4(m^2 - m + n^2 - n) + 2
\end{align*}
Since $d^2 = l^2 + w^2$ has remainder $2$ when divided by $4$, it is not a perfect square.  Thus, $d = \sqrt{l^2 + w^2}$ is irrational.
What I have not shown is why the only integers that have rational square roots are perfect squares.  It hinges on unique factorization.  You can show that $n$ is a perfect square if and only if each prime in its prime factorization appears an even number of times.  For example, $$144 = 2^4 \cdot 3^2 = (2^2 \cdot 3)^2 = 12^2$$ while $12 = 2^2 \cdot 3$ is not a perfect square.  If $n$ is not a perfect square, then some prime in its factorization must appear an odd number of times.  Suppose $n$ is not a perfect square and $$\sqrt{n} = \frac{r}{s}$$ where $r, s$ are integers with $s \neq 0$.  Then 
\begin{align*}
n & = \frac{r^2}{s^2}\\
ns^2 & = r^2   
\end{align*}
If $p$ is a prime that appears in the prime factorization of $n$ an odd number of times, then its appears in the prime factorization of $ns^2$ an odd number of times, while it appears in the prime factorization of $r^2$ an even number of times, a contradiction of unique factorization.  
</s>