Hi and Welcome. My Name is ***** ***** I look forward to assisting you today with your question.
If your Mac came with OS X 10.9 (or any version 10.7 or later), then you can boot into Mac OS X Internet recovery to reinstall the OS X either to external or internal drive. To boot into Internet recovery, restart your Mac and immediately hold down Command, Option and R keys at same time for 10 seconds. This will not work if your Mac came with 10.6 or lower version.
If that is the case, then follow the steps below;
First you have to download the OS X 10.9 Mavericks installation file from App Store. Remember, Apple has removed OS X 10.9 from App Store, so you will only get it if you have already downloaded a copy of OS X 10.9 on to your Mac before. If you never downloaded 10.9 before, you will not get it from App Store. But you can get the 10.10 Yosemite.
If your Mac is not working now, then you need to get access to a Mac. Open App Store, click on Purchases tab and do you see OS X 10.9 Mavericks ? If so, download it.
After downloading, you will see a file named Install Mac OS X on the Applications folder. Now, you have to copy this file to an USB flash drive, so you could boot your Mac from this USB drive to install OS X 10.9 on either the internal drive or external drive.
To copy the OS X Installation file to USB flash drive using this application --> http://diskmakerx.com/
After copying the installation file to USB drive, put the drive to your Mac, restart your Mac and immediately hold down Option key on your keyboard for 10 seconds and this will bring Startup Manager. Select USB drive from the list and press return.
This will boot into Mac OS X installation screen. If you are unable to get the 10.9 installation file from App Store, then you can buy this one --->
Once you are in the installation screen, click on Utilities menu in the top and select Disk Utility. Select your external hard drive in the left column, click on Partition tab. Select 1 Partition. Click Options and make sure GUID is selected. Close it and click Apply or Erase button.
Then close it and follow the onscreen instructions to install OS X to the external hard drive. You can also install to internal hard drive if you want.
Refer this article to download Mavericks from App Store --> http://osxdaily.com/2014/12/30/re-download-os-x-mavericks-installer-from-os-x-yosemite-app-store/
Refer this article to know about installing OS X on external drive --> https://support.apple.com/en-us/HT202796
If you have any questions or would like any additional information, please don't hesitate to ask. Remember, this is not my final answer. So if you have any problems or questions, please let me know by replying in here and I will continue to help you.
I will open this question to all experts in here.
Is this a iMac G5 ?