To prepare a computer for sale or donation, in addition to the steps mentioned in this support article, take these steps:
If you set a firmware password, remove it by running Firmware Password Utility in Recovery mode.
If you activated FileVault in OS X 10.7 or later, turn it off.
If you use Boot Camp, the partition must be deleted
If you created any other data partitions on the internal drive, remove them in Disk Utility.
If privacy is a concern, erase the data partition(s) with the option to zero out data. An SSD doesn't need to be zeroed.
You can't legally or practically transfer any software downloaded from the Mac App Store to the new owner of the machine, even if it was free. That includes OS X, so if you paid for an upgrade OS X 10.7 or later, you must reinstallthe original OS, either from the installation media, if applicable, or by booting into Internet Recovery (option-command-R at the startup chime.)
The new owner will have to repurchase the software, if need be, under his or her Apple ID. If you ever updated the bundled iLife applications (Garage Band, iMovie, and iPhoto) through the App Store, you can't transfer them either.
Remove the machine from your list of registered products. If it's still covered by an AppleCare Protection Plan, transfer the coverage to the new owner by following the instructions in the AppleCare Terms and Conditions (under the heading "Transfer of Plan.")
You cannot leave Mountain Lion on the machine as the license is not transferable. You would not be doing your friend a favor as s/he would never be able to reinstall the OS as it is tied to your Apple ID forever. You need to reinstall the original OS. Here is an excerpt from the SLA: