Each side is split by its gates into fence stretches.
Each stretch gets the fewest equal sections that don’t exceed your maximum spacing: sections = stretch ÷ spacing, rounded up.
Posts sit at every section end and both sides of every gate. Sides that join share one corner post.
Posts are counted one by one, so the plan tells you how many are end, corner, gate and line posts.
Why not just length ÷ spacing + 1?
That shortcut is right for one straight side with no gates. It goes wrong with gates (each one splits the side and adds posts), corners (shared, so counted once), and closed loops (the last post is the first post). Counting post by post avoids all three mistakes.
Worked examples
One straight 100 ft side at up to 8 ft spacing: 100 ÷ 8 = 12.5 → 13 sections, so 14 posts.
A 40 ft side with a 4 ft gate starting 10 ft along: stretches of 10 ft (2 sections) and 26 ft (4 sections); posts = 1 + 2 + 1 (gate) + 4 = 8, two of them gate posts.
A square enclosure, four 25 ft sides joined in a loop: 4 sections per side, 16 sections and 16 posts in total.
A 10 ft picket stretch with 5½ in pickets and 2 in gaps: (120 + 2) ÷ 7.5 = 16.3 → 17 pickets.