You can find this information on the
Park Tools web site.
They provide two formulas. You have to round the answer to the nearest whole number, obviously. The simple one, for a fixed-gear/single-speed:
L = 2C * [(F+R)/4]
where
L = chain length in inches
C = chainstay length in inches, from center of bottom bracket to center of rear hub axle, to nearest 1/8"
F = number of front chainring teeth
R = number of rear cog teeth
A month or two ago I put the equations into an Excel spreadsheet, which is pretty handy.