online advertising

Wednesday, October 12, 2016

Rectangles with integer dimensions

Problem:

Find all rectangles with integer dimensions such that its perimeter is equals to its area.

Solution:

Let the length and width of the rectangle be $ x $ and $ y $ respectively. We have

$ 2(x + y) = xy $

Of course, subject to the constraints that $ x \ge 0 $, $ y \ge 0 $, $ x, y \in \mathbf{Z} $.

The key idea is to factorize this as follow:

$ xy - 2x - 2y + 4 = 4 $
$ (x - 2)(y - 2) = 4 $

Once we have that, we know there are only a handful of integer factorization of 4, and we can now check:

$ (x - 2) = 1, (y - 2) = 4 $ gives $ x = 3 $, $ y = 6 $
$ (x - 2) = 2, (y - 2) = 2 $ gives $ x = 4 $, $ y = 4 $

So there we go, there are only two rectangles that satisfy the requirements.