I'm try to find a way to properly calculate the number of columns given the number of rows and the number of items per row.
For example:
I have 11 items I would like to lay in a table that has 2 rows and each row can only hold 5 items, so this means that the table should have 3 columns, 2 rows with 5 items each and 1 row with a single item.
I have already tried the following formula:
column_count = (item_count / row_count) + (item_count - row_count) / row_count
Which doesn't return the correct number of columns given certain item counts for example, given 16 items and a limit of 5 items per row, the formula should return 4 but it returns 5.