Bethe ansatz and inverse scattering transform in a periodic box–ball system