**The main thing you’re missing is that each payroll deduction is tied up for a different length of time.** Only your first deduction waits six months; your final deduction waits very little. With regular contributions, the average wait is roughly three months.

Assuming U.S. taxes, a 25% marginal tax rate, and that you can sell promptly at the purchase-date market value, the ESPP likely comes out ahead.

There are three corrections to your calculation:

1. **A 5% discount produces a 5.26% return on your money.** You pay $95 for $100 of stock, so your profit is $5 ÷ $95. After 25% tax, that becomes:
   \[
   \frac{5}{95}(1-0.25)=3.947\%
   \]

2. **That return applies to every contribution, regardless of when it was deducted.** A December contribution gets the same percentage discount as a July contribution despite being tied up for much less time. Doubling the return therefore understates the annualized return for the staggered contributions.

3. **For a typical U.S. tax-qualified ESPP, an immediate sale makes the discount ordinary wage income.** Any change between the purchase-date market value and your sale price is a separate capital gain or loss. Your 25% assumption can still work numerically if that is your applicable marginal tax rate, but there is no special flat 25% short-term capital-gains rate. [IRS Publication 525](https://www.irs.gov/publications/p525)

A direct dollar comparison is more useful than annualizing. Suppose you contribute **$1,000 on the first of each month, July through December**, and sell at year-end:

| Through December 31 | Approximate benefit |
|---|---:|
| ESPP: $6,000 × 3.947%, after tax | **$237** |
| Loan: six $1,000 repayments saving interest for 6, 5, 4, 3, 2 and 1 months at 8% | **$140** |
| ESPP advantage before fees and price movements | **$97** |

After selling, you could put the proceeds toward the loan, reserving enough for taxes. This comparison measures the benefit of delaying those extra loan payments until year-end.

**If you instead deposited the entire amount on July 1, your original conclusion would be approximately right:** the ESPP’s 3.947% after-tax gain would be slightly below six months of interest savings at 8%, approximately 4%.

Before participating, check the plan’s sale restrictions, share-release delay, fees, and your total applicable tax rate. A prompt sale still involves some price risk between purchase and execution, so the profit is not guaranteed. Also, if reducing your loan interest would reduce an available student-loan interest deduction, the effective benefit of repayment is lower than 8%. [IRS student-loan interest deduction rules](https://www.irs.gov/taxtopics/tc456)

With regular payroll deductions and prompt, inexpensive sales, the ESPP appears financially better under your assumptions—but the extra dollars may still be small enough that you prefer the simplicity of paying down the loan.