'How to calculate how many cubes a light beam will pass through a rectangular prism from one corner to the other?

I have some transparent 1x1x1 cubes arranged in a 72x98x56 bigger rectangular prism. I shine a light beam through the two furthest corners of the rectangular prism.

How many cubes does the light beam pass through?

Just having some mental gymnastics



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source