Set the edge lengths of a rectangular prism. The prism is packed with unit cubes whose edge is the unit fraction that fits every edge: ½ when an edge is fractional, otherwise 1.
Add layer packs the prism one horizontal layer at a time. Each layer holds (length ÷ cube edge) × (width ÷ cube edge) cubes, so the total is cubes per layer × number of layers.
Counting the cubes gives the same volume as V = l × w × h, measured in cubic units.