OK, that sounds pretty easy but let me just clarify what you need:
Say you have a line 12 units long and a max length value of 5.
5 goes into 12 twice, so there must be 3 lenghts overall.
3 into 12 goes 4 so the result of line length 12 and max length 5 is 3 lengths of 4 units.
Do I understand you correctly?