It can be fun to play "what-if" games -- including with stocks. It can sometimes get frustrating, though, such as when you're wondering how much money you'd have if you'd invested in this or that company a decade or two ago. It's even worse if you did buy the stock back then, but then sold way too early.

Here's a look at what your stake would be worth if you'd invested $10,000 in Amazon.com (AMZN -0.14%) 20 years ago. Let's get to the answer first: Your investment would now be worth $1,183,328. Yup -- your investment would have increased in value 118-fold. If you'd started with just $1,000, you'd be sitting on $118,332, enjoying an average annual gain of roughly 27%, well above the S&P 500's 9.2% average.

Person squinting at something through glasses.

Image source: Getty Images.

Here's another way to look at the question: How many shares would you have now if you'd bought 100 shares 20 years ago? Well, the shares split 20-for-1 in that period, turning your 100 shares into 2,000. The total gain would still be a 118-fold increase, though.

Don't kick yourself too hard. Many of us (myself included) bought and then sold Amazon along the way. Remember that most stocks, even great ones, don't go up in a straight line. There will be ups and downs and slow years.

Fortunately, it's not too late to buy into Amazon.com now. The shares are even appealingly valued at current levels, with a recent forward-looking price-to-earnings (P/E) ratio of 35, below the five-year average of 47.

There's still a lot of potential growth ahead. The company's cloud-computing platform, Amazon Web Services, is a leader, with its revenue rising 17% in the last quarter, year over year. (Amazon's overall revenue grew by 9%, which is still impressive given the company's immense size.)