A charged capacitor dumps its energy as heat in a resistor, with power that fades exponentially. Adding up that power over time is an integral that needs one substitution, and the answer is exactly the energy that was stored: ½CV².