Iterative solution of the scattering by an arbitrary configuration of conducting or dielectric spheres