If you've ever dreamed of having a retirement account stuffed with $1 million or $2 million -- or, gasp, more! -- you might have assumed that such a goal was just unrealistic or impossible for you.

That may not be the case. Whether you're able to amass a million or more dollars, you probably can amass much more than you thought -- by acting on the secret to building a huge retirement account. The secret isn't just socking away massive sums every year, either -- it's simply the mathematical principle of compounding.

Alarm clock on pile of dollar bills

Image source: Getty Images.

An intro to compounding

You're probably familiar with compounded growth, at least in terms of a bank account and interest. Here's a simple example: Imagine that you have $1,000 in a bank account that pays 10% interest, compounded annually. (Yes, that 10% rate seems laughable now, but past years such as 1984 have seen such rates. Indeed, in the early 1980s, rates in the high teens could be found!) After one year, you'll earn $100 and will have $1,100 in your account. The next year, you'll collect 10% of $1,100, or $110, for a new total of $1,210. The year after, the account will grow by $121, totaling $1,331.

The interest rate may be 10%, but that doesn't mean that you collect $100 every year. Instead, not only does your account balance grow every year, but the amount by which it grows also grows. Once your account is worth $10,000, a 10% increase would be a whopping $1,000!

Focus on stocks

Of course, we can't count on 10% interest rates too often, so savings accounts and CDs and even bonds are not the best way to build a huge retirement account over the long run. The stock market, though, does offer you the chance to enjoy returns rather close to that. Over many decades, the S&P 500 has averaged annual returns of close to 10%. Check out how a single $10,000 investment would grow if it increased by 10% annually:

After...

$10,000 Grows, at 10%, to...

10 years

$25,937

20 years

$67,275

30 years

$174,494

40 years

$452,592

50 years

$1.2 million

60 years

$3.0 million

70 years

$7.9 million

Table and calculations by author.

The table above shows the amazing power of compounding, as those hefty sums are built with only a single $10,000 initial investment. Of course, the really big numbers need really long periods of time. You may not have 50 or 60 years during which to grow your retirement nest egg (though if you're a precocious 15-year-old reading this article, you do!), but note what kind of inheritance you may be able to leave your kids or grandkids with just a single modest investment! Let's get more realistic for you now, though.

Hand drawing upward sloping arrow over graph of dollar signs getting bigger on a chalkboard.

Image source: Getty Images.

Realistic compounding -- for you

The results in the table above may be hard to achieve if you don't have those long time periods, but if you can sock away more than a single $10,000 sum, you can amass a lot of money in less time. Check out the examples below, which use a more conservative average annual return of 8%:

Growing at 8% for

$10,000 Invested Annually Yields

$15,000 Invested Annually Yields

$20,000 Invested Annually Yields

5 years

$63,359

$95,039

$126,718

10 years

$156,455

$234,683

$312,910

15 years

$293,243

$439,865

$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,189

$2,446,918

Table and calculations by author.

The table demonstrates that even if you're 60 years old and want to retire in five years, you might still amass more than $125,000 if you can be very aggressive about it. (It will be easier, of course, if you're in a two-income household or earn a sizable income.)

Your amazing retirement plan

If you're ready to put compounding to work for you or are already doing so, take some time to come up with a retirement plan that will incorporate it. Figure out how much money you'll need in retirement and how you will amass that sum. Consider using tax-advantaged retirement accounts, such as Roth IRAs and traditional IRAs, as well as Roth and traditional 401(k)s. Roth accounts offer the chance of tax-free withdrawals in retirement, which can be a big deal -- especially if you've accumulated some big bucks over a long period.

Factor Social Security income into your plan, too, as it's likely to provide a significant chunk of your retirement income. Know that the average monthly retirement benefit was recently $1,404, which amounts to nearly $17,000 per year -- but if your earnings have been above average, you'll collect more than that. It will never be a princely sum, though, as the maximum monthly Social Security benefit for those retiring at their full retirement age in 2017 was just $2,687, or about $32,000 for the whole year. It's smart to look into strategies that can maximize your Social Security income, too.

With a little planning and discipline, you may be able to retire as a millionaire or multimillionaire -- or you can at least end up with more money than you thought you'd have.