This is a collection of mathmatic equations that has helped me in a variety of design projects.
Given the amount of objects, and their width or height (e.g. in pixels) we can calculate the width or height of an area that these objects fit in.
amount × size = area
Taking gutters/margins into account
amount × (size + gutter) = area
Given the width or height of an area we can retrieve the amount of objects that can fit in that area, including their widths or heights.
area ÷ size = amount
Taking gutters/margins into account
area ÷ (size + gutter) = amount
Substracting or adding to the result of (size + gutter)
helps us to deal with leading and trailing gutters.
If we'd like to omit leading and/or trailing gutters, we simply substract or add it from the result of the size with gutter
area ÷ (size + gutter) ÷ (leading + trailing) = amount
amount × (size + gutter) ÷ (leading + trailing) = area