This paper presents a new approach for minimizing line losses and finding the optimal capacitor allocation in a distribution system. The problem is formulated as a linear programming problem and is solved by a recursive process. Since this method does not need any matrix inversion, it can save computational time and memory space. The economic justification of capacitor installation is also discussed and two practical examples demonstrate the approach's effectiveness.