This paper deals with the unique solvability of the inverse problem for second-order differential operators having a singular potential. It is shown that the coefficients of the differential operator can be determined from the spectral data. Then, we construct the theoretical bases and provide a numerical algorithm for solving the inverse problem of spectral analysis and finding the potential function. Finally, some numerical examples are considered to demonstrate the applicability of the algorithm.