>06.54 // there's no simple formula //
There would appear to be some exceptions.
Given the l,w,h measurements of the smaller boxes fitting exactly and respectively into the l,w,h dimensions of the larger cuboid,
then no unused space within the cuboid would present itself.
Therefore the optimum number of smaller boxes packaged could be easily obtained as demonstrated by >14:19
Similarly, a smaller box in the shape of a cube allows the optimum number to be found straight forwardly.
Note, where the larger cuboid (l,w,h) dimensions were not a multiple of the side of the cube, rounding down would be the order of the day.
Clearly the orientation of the smaller boxes is a factor, this engenders different unknowns in unused space, couple this
with a miscellany of boxes of different sizes being put into the container along with their dimensions in rational numbers,
it is highly unlikely a polynomial algorithm exists to determine the optimum. Since computer science was alluded to earlier,
they will appreciate problems of this nature lend themselves to 'NP Completeness'.
The link below illustrates a program that is probably based on a heuristic or approximation algorithm.
https://www.engineeringtoolbox.com/smaller-rectangles-within-larger-rectangle-d_2111.html
Markedly, this program computes (very quickly) a number of smaller rectangles (of one type) which fit into a larger rectangular container, however not the optimum number.
Enter the following dimensions into the fields provided;
58 (width) and 40 (height) - Large Rectangle and
16 (width) and 12 (height) - smaller rectangle.
Space between rectangles = 0
It does not take much imagination to envisage if the dimensions for depth (38 and 12) are added, the container only caters for a total of 30 boxes. In relation to OP question this is clearly not the optimum.
JJ109 demonstrated 32 boxes. With a little rearrangement, my effort yielded 33 boxes - See link;
https://ibb.co/f4Xzc5N
Hope this helps.