Partition of a rectangle into squares problem

Problem statement

Show that a rectangle can be partitioned into finitely many squares if and only if the ratio of its sides is rational.


Clearly, every rectangle with rational ratio of sides can be partitioned into finitely many equal squares. Thus, the interesting part of the problem is the "only if" one.

Proof via Dirichlet's simultaneous rational approximation theorem

Without loss of generality, we may assume that both sides of our rectange are greater than $1$. We can choose a positive integer $q$ such that the product of every coordinate of every vertex of every square in our partition becomes almost an integer after multiplication by $q$. So, we may assume that all these coordinates differ from integers by, at most, $\frac 15$. Now let $a$ and $b$ be the horizontal and the vertical side of our rectangle, respectively, and let $s_i$ be the sides of the squares in the partition. Denote by $\tilde x$ the nearest integer to $x$. Now, draw the horizontal lines at all half-integer heights (i.e., the heights $\pm\frac 1 2,\pm\frac 3 2,\dots$) and look at the total length $L$ of these lines within our rectangle. On one hand, we have $L=a\tilde b$. (There are $\tilde b$ lines intersecting our rectangle and each of them intersects it by an interval of length $a$.) On the other hand, looking at what happens in each square, we get $L=\sum_i s_i\tilde s_i$. Thus $a\tilde b=\sum_i s_i\tilde s_i$. Similarly, drawing the vertical lines through half-integer points, we arrive at the identity $b\tilde a =\sum_i s_i\tilde s_i$. Thus $a\tilde b=b\tilde a$, i.e., $\frac a b=\frac {\tilde a}{\tilde b}\in\mathbb Q$.