Shut down your Mac, turn it on while holding down Command+Option+R keys. Dependent upon the model of computer you'll most likely see a spinning globe and a prompt to connect to a Wi-Fi network. Connect to the network of your choosing and then after several minutes you should get prompted to select your language. After these prompts you'll be taken to a screen that should look like the following:



Select Disk Utility from the options


Select the Internal drive to the right (usually named Macintosh HD and then select Erase



Select Erase again after selecting the file formating options (generally the default options will suffice). 


Once drive is erased you can then quit Disk Utility and return to the initial menu to Reinstall macOS, but if you're selling or recycling the machine no need to reinstall an OS as it can take about 30-45 minutes to complete. You can just reboot and/or shutdown the machine.