We all would like to be millionaires by the time we retire. With Social Security income likely to provide only a modest fraction of the income we need, most of us will have to come up with the rest of our needed cash flows on our own.

Fortunately, if you invest regularly and effectively for a long time, you can achieve a comfortable retirement. The stock market is hard to beat for that -- but which stocks should you invest in? Here are some categories to consider.

Image source: Getty Images.

## Some preliminary math

Let's start with a little math, though, to help you see how you can become a millionaire. It takes time and diligence, and much will depend on how much you can sock away each year and how quickly it grows.

The table below shows how much you might amass over various periods, investing various amounts:

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

Data source: Calculations by author.

The overall stock market has averaged annual returns close to 10% over long periods, but you may average more or less during your investment time frame. So the table above uses 8% to be a bit conservative.

Now let's move on to what kinds of stocks can make you a millionaire.

## Boring stocks

You might assume that you'll need to get lucky and invest in companies that end up turning in amazing performances over long periods -- such as Amazon.com or Netflix. That's not true, though. Many boring companies can build wealth for you at a good clip, too. Check out the examples below:

Company

20-Year Average Annual Return*

Sherwin-Williams

20%

Union Pacific

17.8%

Nike

17%

Public Storage

15.1%

Altria

14.8%

Clorox

12.6%

Home Depot

11.1%

Toronto-Dominion Bank

10.8%

Procter & Gamble

10.6%

General Mills

10.1%

United Parcel Service

8%

CVS Health

7.8%

S&P 500

6%

Source: Theonlineinvestor.com. *With dividends reinvested.

Those companies are focused on exciting businesses such as paint, railroad transport, shoes, storage units, tobacco products, cleaning products, home improvement supplies, banking, shampoos, cereal, parcel delivery, and health supplies. Yawn! But all of them outperformed the S&P 500's performance, and most exhibited fairly rapid growth, far exceeding the 8% example in the table up top.

## Dividend stocks

Next up are dividend-paying stocks, which you might assume are also boring. Not so! (After all, even Apple and Microsoft pay dividends these days.) More than one study has found dividend stocks outperforming non-dividend payers. For example, when researchers Eugene Fama and Kenneth French examined stock-performance data from 1927 to 2014, they found that dividend payers outperformed non-payers, averaging 10.4% annual growth vs. 8.5%.

The beauty of a portfolio full of dividend payers is that it will generate income regularly, without your having to sell any of your holdings. If your portfolio is worth, say, \$500,000 and it has an overall dividend yield of, say, 4%, you're looking at \$20,000 in income annually just from dividends -- which would complement your Social Security benefits nicely. Even better, healthy and growing companies tend to increase their payouts each year, which means increasing dividend income each year -- and that can help you keep up with inflation.

It's not hard to find some solid dividend yields, either. Here are some recent yields from some familiar companies:

Stock

Recent Dividend Yield

AT&T

6.9%

Chevron

5.7%

AbbVie

5%

MetLife

4.7%

Duke Energy

4.7%

Walgreens Boots Alliance

4.5%

Verizon Communications

4.2%

Citigroup

3.9%

3M

3.5%

Kellogg

3.3%

PepsiCo

3%

Source: Yahoo! Financial.

## Growth and value stocks

Two other classifications of stocks are growth stocks and value stocks -- in other words, ones that growth investors or value investors would seek. Growth investors chase companies that are growing rapidly and aren't afraid to pay rich prices for them. Amazon.com, for example, has usually looked rather overvalued, but then has kept rising over many years, albeit in a jagged line. Not all growth stocks keep growing rapidly, though, and some are so overvalued that they pull back, hurting investors.

Value investors, on the other hand, seek a margin of safety by favoring stocks that seem significantly undervalued relative to their intrinsic worth. These companies can be less exciting than high-flying market darlings, but value investors tend to do quite well, and their ranks include Warren Buffett.

Fortunately, you don't necessarily have to choose between value and growth stocks. After all, the best investments should be both growing at a good clip and also be undervalued.

## Most or all stocks

Finally, if you're going to study stocks and choose which individual ones to invest in and when to do so, that will take a lot of time and skill -- which many of us don't have enough of. Fortunately, you can also become a millionaire simply by investing in low-fee, broad-market index funds, such as those that track the S&P 500 or the overall market. If the stock market averages 9% or 6% growth during your investment period, an index fund that tracks it will also return roughly 9% or 6%.

There's no shame or compromise in opting for index funds. If you're diligent and determined and have some years ahead of you, you can become an index fund millionaire, too.

Editor's note: This article has been corrected. The name of the stock in the second row of the second table is Union Pacific.