# Firing a laser through a pile of cubes

Find the number of integer triples $(a,b,c)$ such that there exists $0<t<1$ with

$| a + \frac{1}{2} - 589t| < \frac{1}{2}$

$| b + \frac{1}{2} - 989t| < \frac{1}{2}$

$| c + \frac{1}{2} - 1189t| < \frac{1}{2}$

• I actually think this is on-topic. At first it appears as a textbook-style puzzle but the title hints that it isn't. In fact, the solution due to f'' shows it isn't a textbook style problem at all and instead has a very clever solution. – Tyler Seacrest Feb 3 '16 at 21:59

Divide 3-space into unit cubes such that their vertices are lattice points. How many cubes contain part of the line segment with endpoints $(0,0,0)$ and $(589,989,1189)$?
The line segment crosses $588$ integer $x$-coordinates, $988$ $y$-coordinates, and $1188$ $z$-coordinates, entering a new cube each time. Because $589$, $989$, and $1189$ are pairwise relatively prime, it never crosses two integer coordinates at the same time. The total number of cubes it passes through is therefore $588+988+1188+1=2765$.