It sounds like you are getting error message 4005 when trying to restore your device after it had started rebooting itself over and over again. I recommend the following article which mentions this error code named:
iOS: Restore errors 4005, 4013, and 4014
Try these steps to resolve the issue:
- Install the latest version of iTunes.
- Restart your computer.
- Make sure your computer is up to date. If an update requires a restart, check for updates again after you restart.
- Restore using another USB cable.
- Restore your device on another computer.
If you continue to see error 4005, 4013, or 4014 when you restore your device, contact Apple for support.
Thank you for using Apple Support Communities.