Diagonal of a Grid
Lesson · Intermediate
Number Theory

If you draw the diagonal of an grid, then the diagonal is split into parts
The diagonal intersects the interior vertical grid lines and the interior horizontal grid lines
However, some of these intersections are the same point: this happens whenever the diagonal passes through an interior lattice point
Let
Write , where
The diagonal from to has equation
For both and to be integers, must be a multiple of
Therefore, the lattice points on the diagonal are
Hence there are interior lattice points
At each of these points, an intersection with a vertical line and an intersection with a horizontal line are actually the same intersection
Therefore, the number of distinct intersections on the diagonal, excluding the endpoints, is
These intersection points split the diagonal into one more part than the number of intersections. Therefore, the number of parts is
Since , we get
The diagonal of an grid passes through exactly cells. Find all possible positive integers
We need
so
Let
Then
Since , we have , so
Therefore,
For , , so
For , , so this does not work
For , , so
For , , so this does not work
Therefore, or
A rectangular grid has 120 cells in total. Its diagonal passes through 25 cells. Find its dimensions.
Let and write , where
Since the grid contains 120 cells
so
Therefore,
Also, the diagonal passes through 25 cells, so
Substituting and
Therefore,
We need both and
The only possibility is
Hence
Together with
we get up to order
But , which contradicts
Therefore, no such rectangular grid exists.
Suppose we have an 3D grid and draw the space diagonal from to
The number of unit cubes the diagonal passes through is
Consider an grid and draw the space diagonal from to
We want to find how many unit cubes the diagonal passes through.
The diagonal intersects interior planes perpendicular to the -axis, interior planes perpendicular to the -axis, and interior planes perpendicular to the -axis
So at first we have
intersections.
However, some of these intersections occur at the same point.
Intersections of Two Families of Planes
The diagonal intersects an -plane and a -plane at the same point exactly when the corresponding point has both - and -coordinates integers
The number of such interior points is
Similarly, the numbers of simultaneous intersections are and
Therefore, we subtract
But now a point where all three families of planes meet has been subtracted too many times.
The number of interior points where all three coordinates are integers is
so by inclusion-exclusion, we add these back.
Therefore, the number of distinct interior intersection points on the diagonal is
which simplifies to
These intersection points divide the diagonal into one more part than the number of intersections.
Therefore, the number of cubes crossed is