Warren Buffett is one of the most famous and successful investors in the world, so when he gives advice, it often pays to listen.

While everyone's investing strategy will differ based on personal preferences, there's one type of index fund that Buffett has long recommended. This fund can fit into any portfolio, it requires next to no effort on your part, and it could even help you become a millionaire: the S&P 500 index fund.

More powerful than it seems

An S&P 500 index fund follows the S&P 500 itself, containing the same stocks as the index and mirroring its long-term performance. This index has high standards, so the companies in the S&P 500 are some of the largest and strongest organizations in the U.S.

Buffett swears by this investment, and back in 2008, he put his money where his mouth was with a $1 million bet.

Buffett bet that over 10 years, an S&P 500 index fund would outperform five actively managed hedge funds. His investment, the Vanguard 500 Index Fund Admiral Shares (NASDAQMUTFUND:VFIAX), not only won, but it trounced the competition -- earning returns of nearly 126% while the hedge funds averaged just 36%.

Perhaps the best part of an S&P 500 index fund, though, is that it's a passive investment that requires next to no upkeep. You never need to choose individual stocks, research companies, or decide when to buy or sell. Simply invest whatever you can afford, then wait for your money to grow.

It's also a smart choice during periods of volatility. The S&P 500 itself has an impeccable track record when it comes to recovering from downturns. Whether we face a recession, bear market, or any other rough patch, an S&P 500 index fund is almost guaranteed to bounce back.

Building a million-dollar portfolio

With enough time and consistency, it's possible to earn well over $1 million with an S&P 500 index fund.

Historically, the index has earned average returns of around 10% per year. While the short term can be volatile, all those ups and downs have averaged out to roughly 10% per year over the long run.

If you were to invest, say, $300 per month while earning a 10% average annual return, here's approximately how much you could accumulate depending on how many years you invest:

Number of Years Total Savings
20 $206,000
25 $354,000
30 $592,000
35 $976,000
40 $1,593,000

Data source: Author's calculations via Investor.gov. 

The two key factors affecting your total earnings are the amount you invest each month, and how long you give your money to grow.

Even if you don't have 40 years to build your savings, if you can invest a little more each month, it could dramatically increase your earnings. Or if you can't afford to invest much monthly, giving your money a few more years to grow will also boost your savings exponentially.

The stock market can be intimidating, especially during periods of volatility. But S&P 500 index funds are one of the safer investments out there, and they've earned Buffett's seal of approval. By getting started investing now, you'll be on your way to generating wealth that lasts a lifetime.