Accidentally formatted High Sierra operating system, how to reinstall?
Try using the build in Restore. 

As the computer restarts, hold down the Command (⌘) – Option (⌥) – R combination immediately upon hearing the startup chime.

Follow the instructions on the screen.