The Casimir energy for the transverse oscillations of a piecewise unif
orm closed string is calculated. The string consists of 2N pieces of e
qual length, of alternating type I and type II material, and is taken
to be relativistic in the sense that the velocity of sound always equa
ls the velocity of light. By means of a new recursion formula we manag
e to calculate the Casimir energy for arbitrary integers N. Agreement
with results obtained in earlier works on the string is found in all s
pecial cases. As basic regularization method we use the contour integr
ation method. As a check, agreement is found with results obtained fro
m the zeta function method (the Hurwitz function) in the case of low N
(N=1-4). The Casimir energy is generally negative, and the more so the
larger is the value of N. We illustrate the results graphically in so
me cases. The generalization to finite temperature theory is also give
n. (C) 1997 American Institute of Physics.