The potential difference across the capacitor
V0 = Q/C = 20/5 = 4V
The initial current,
i0 = V/R = 4/5 = 0.8A
τ = CR = 20*5 = 100 µs
The current in the resistor at any time t
i = i0e-t/τ
The heat dissipated,
After substituting and simplifying, we get
H = 4.7 µJ