The paper is dedicated to solving the generalized periodic discrete‐time Sylvester matrix equation, which is frequently encountered in control theory and applied mathematics. An iterative algorithm for this equation is presented. The proposed method is developed from a point of least squares method. The rationality of the method is testified by theoretical analysis. The presented approach is numerically reliable and requires less computation. Two numerical examples illustrate the effectiveness of the raised results.