A new analytical solution of the Helmholtz equation in spherical coordinates for an infinite homogeneous space, as well as the solution of the boundary problem for a piecewise-homogeneous medium (space divided into homogeneous domains with various dielectric permittivities of the spherical symmetry borders) has been obtained. The application of the derived formulas to spherical nanoparticles of metal makes it possible to record a mathematical relation to the localized plasmon resonance, which connects the resonance parameters of such a system and the electromagnetic waves. The equation of plasmon resonance confirms the known experimental result of significant amplification of an electromagnetic field at the localized plasmon resonance. The condition of the optical resonance obtained in the work is applicable to layered spheres with an arbitrary number of layers of any size and material.