Method of variation of constants for difference equations and its application to the calculation of atomic integrals