We can use the formula for the future value of an ordinary annuity to solve this problem:
FV = Pmt x [(1 + r)^n - 1] / r
Where FV is the future value, Pmt is the periodic payment, r is the interest rate per period, and n is the number of periods.
In this case, Sam will be depositing $5,000 each year for 65 - 24 = 41 years. The interest rate is 6% per year (or 0.06).
FV = 5000 x [(1 + 0.06)^41 - 1] / 0.06
FV = 5000 x (146.93) / 0.06
FV = $1,234,709.67
Therefore, when Sam is 65 years old, he will have approximately $1,234,709.67 in his retirement account, assuming he makes annual deposits of $5,000 and earns an annual interest rate of 6%.