Despite stereotypes that accuse young people of mishandling their finances, Millennials are actually more likely than Baby Boomers and Gen Xers to contribute money to their 401(k) plans. But if you want to retire rich, simply having a tax-free retirement account may not be enough. CNBC recently broke down exactly how much of your salary you need to contribute in order to hit the $1 million mark when you withdraw your 401(k) funds at age 65.

Many financial advisors recommend contributing 10 to 15 percent of your gross income to your retirement plan—or less, if that number exceeds $19,000, the 401(k) contribution limit for 2019. Depending on the rate of return on your investment portfolio and your salary, you could contribute less than that and still retire a millionaire. The key is starting early enough: The later you wait to open your 401(K), the more of your salary you'll need to set aside in order to catch up.

Here's CNBC's break down of what you need to invest per month to save $1 million by retirement, starting at three different ages and looking at three possible rates of return.

Age 25

With a 4 percent rate of return: $843.24 per month
With a 6 percent rate of return: $499.64 per month
With an 8 percent rate of return: $284.55 per month

Age 30

With a 4 percent rate of return: $1090.78 per month
With a 6 percent rate of return: $698.41 per month
With an 8 percent rate of return: $433.06 per month

Age 40

With a 4 percent rate of return: $1938.57 per month
With a 6 percent rate of return: $1435.83 per month
With an 8 percent rate of return: $1044.53 per month

Of course, not everyone can contribute this much to a 401(k) consistently throughout their career. Salaries and living expenses fluctuate, and even if dropping 15 percent of your paycheck into a retirement plan is easy to do now, that may not always be the case. The reverse may also be true.

If you can't meet the goals laid out above at this point in your life, that doesn't mean you should delay saving for retirement altogether. When it comes to a 401(k), financial planners emphasize that putting aside something—even 1 or 2 percent of your salary—is much better than saving nothing at all. Not sure where to begin? Here are some tips for getting started with your 401(k).

[h/t CNBC]