Measure the length of your rail from one end to the other.
Measure the width of one baluster you plan to use.
Add one baluster width to the measurement of your rail and record it as "TL."
Get the on-center spacing requirement for your baluster and add it to one baluster width. Call this number "OC."
Divide "TL" by "OC." If you have a rail length of 200 inches and a baluster width of 2 inches, "TL" ends up being 204. If you have an on-center spacing requirement of 4 inches, "OC" becomes 6. Given these variables, you should end up with 34 as your final result. The resulting number indicates how many balusters you need to install on your rail. Call this number "TB."
Multiply "TB" by the width of a baluster and subtract this number from "TL." As per the previous example, you end up with 204 - (34 * 2) = 136. Divide the result by "TB + 1," giving you the space you must place between each baluster.