Fine and Wilf's theorem has recently been extended to words having threeperiods. Following the method of the authors we extend it to anarbitrary number of periods and deduce from that a characterization ofgeneralized Arnoux-Rauzy sequences or episturmian infinite words.