Where;
F is the force applied to the compression spring (lbs)
k is the spring rate, often specified in catalogs. (lbs/inch) Also, see below for calculation of spring rate.
Lf is the length of the spring with zero deflection, ie, no force applied. Often called "free length" (inches).
Ld is the length of the spring with the force F applied. (inches).
There is a comprehensive compression spring calculator/designer here at efunda.