So you'd like to retire a millionaire. Who wouldn't? (Well, maybe billionaires.) In many ways, it all boils down to math: Invest a particular sum (ideally regularly), earn a particular return, and in a particular number of years, you'll get there.

A single lottery ticket might work, but really, whether you buy a ticket or not, your odds of winning a big jackpot are nearly the same. Instead, consider a much more reliable -- and easy -- strategy: investing in stocks over many years. Here's how to do that through index funds.

Person sitting at a table and smiling at a propped-up tablet.

Image source: Getty Images.

Here's the math for becoming a millionaire

The table below shows how you can build wealth over different multiyear periods with regular investments of various sizes. Clearly, achieving millionaire status is possible, but you'll need to be diligent to get there. And if you don't have lots of decades ahead of you, you'll want to be investing a lot each year.

Growing at 8% for...

$10,000 Invested Annually

$15,000 Invested Annually

$20,000 Invested Annually

5 years

$63,359

$95,039

$126,718

10 years

$156,455

$234,682

$312,910

15 years

$293,243

$439,864

$586,486

20 years

$494,229

$741,344

$988,458

25 years

$789,544

$1,184,316

$1,579,088

30 years

$1,223,459

$1,835,188

$2,446,917

Data source: Calculations by author.

That 8% annual average growth rate isn't guaranteed, either. The stock market's average annual return over long periods is close to 10%, but it will likely be at least a little higher or lower over your particular investing time frame, and may be a lot higher or lower.

Here are four index funds that may deliver average annual gains of 8% to 10%, on average, over your investing time frame.

Four promising index funds

SPDR S&P 500 ETF

As a reminder, an index fund is a mutual fund or exchange-traded fund (ETF) that aims to deliver approximately the same returns as a particular index by holding the same securities in the same proportions. Index funds are great for most of us, with the best index funds offering solid performance, low fees, and simplicity. Buy the shares and then trust in the long-term growth of the economy.

The SPDR S&P 500 ETF (SPY -0.18%) tracks the S&P 500 index of 500 of America's biggest companies, such as CVS Health, Amazon.com, Johnson & Johnson, and Pfizer. There are thousands of publicly traded companies in America, but these 500 together make up around 80% of the entire market.

Lots of financial services companies offer S&P 500 index funds, and there's a good chance that your company's 401(k) plan offers one, too. Any such fund, as long as it's a low-fee index fund, will be a solid candidate for your portfolio.

Over the past 10 and 15 years, the SPDR S&P 500 ETF has averaged annual gains of 13.6% and 9.4%, respectively.

Vanguard Total Stock Market ETF

If you'd rather spread your dollars (or some of your dollars) across an index that represents roughly 100% of the total U.S. market instead of just 80%, look at a "total stock market" index fund, like the Vanguard Total Stock Market ETF (VTI -0.30%). It contains more than 4,000 different stocks, including lots of smaller- and small-cap companies, such as BJ's Wholesale Club and Texas Roadhouse.

Over the past 10 and 15 years, the Vanguard Total Stock Market ETF has averaged annual gains of 13.4% and 9.5%, respectively.

Vanguard Total World Stock ETF

You can do very well over the long run just by sticking with an S&P 500 index fund or a total stock market fund, but for those interested, you can spread your dollars even wider by opting for a "total world stock market" fund. Consider the Vanguard Total World Stock ETF (VT -0.57%). It encompasses more than 9,000 stocks from countries around the world. Examples include Taiwan Semiconductor, Toyota Motor, Royal Bank of Canada, and of course, all those companies in the previous two index funds.

Over the past 10 years, the Vanguard Total World Stock ETF has averaged annual gains of 9.6%. It doesn't yet have a 15-year average.

Invesco QQQ ETF

Finally, if you'd like to aim for a higher growth rate than those offered by index funds targeting much of the United States or world market, consider the Invesco QQQ ETF (QQQ 0.01%). The focus of the Invesco QQQ ETF is much narrower, as it tracks the Nasdaq-100 Index of the 100 largest non-financial companies listed on the Nasdaq stock exchange, based on market cap. These are mostly well-known growth stocks. Here are the recent top holdings:

  • Apple
  • Microsoft
  • Amazon.com
  • Tesla
  • Alphabet
  • Meta Platforms
  • Nvidia 
  • PepsiCo
  • Costco 

Other components include Starbucks, Airbnb, and Intuitive Surgical. Over the past 10 and 15 years, the Invesco QQQ ETF has averaged annual gains of 18.4% and 14.6%, respectively.

With the overall market slumping significantly in recent months, and many growth stocks being hit especially hard, this is a great time to invest in one or more index funds, as prices are low. Give these ETFs some thought and start investing in earnest if you're aiming to be a millionaire.