Compounding works best over the long term, but even short-term investments can benefit from compounding.