With climate change a growing problem, more and more people are looking to put their investing dollars into companies that are taking tangible steps to fight it. But while supporting companies that are making the world better is nice, investing shouldn't be a charitable endeavor. The good news is that there are companies out there doing good for the environment and the world, while also doing well for investors' wallets.

Three of my favorite green stocks to buy may surprise you:

Company Market Cap Dividend Yield 5-Year Total Returns Waste Management Inc. NYSE:WM) $38.1 billion 1.9% 179% Nucor Corp. NYSE:NUE) $21.1 billion 2.3% 68% Trex Co. NYSE:TREX) $3.3 billion n/a 430%

Despite coming from industries typically known for causing pollution and environmental problems, these companies have strong green bona fides. And while their environmental efforts reduce pollution and carbon emissions, they also boost profits and give them strong competitive advantages. Keep reading to learn what makes these three legitimate green stocks, and why they're right for your portfolio.

Turning trash into cash

Waste Management is best-known for big green garbage trucks and operating landfills. But it also does more to reduce the environmental impact of all that trash than just about any company on Earth. This includes operating over 140 facilities that separate and process recyclables like steel, aluminum, and glass, and also organics like yard and food waste that it uses to fuel energy.

According to the company's 2017 sustainability report, its recycling segment recovered sufficient raw materials to make 10.7 million tons of paper, metal, plastic, and glass, and saved 62.5 billion gallons of water. The timber resources alone were enough to produce 2 trillion sheets of paper. In sum, its massive recycling efforst kept 37.5 million cubic yards of materials out of its landfills in 2016.

Waste Management is also one of the biggest U.S. producers of biomethane -- natural gas that, in this case, it created by the normal decay of the materials in its landfills. The company captures it and sells it, or uses it for energy production in power plants or as vehicle fuel. This significantly reduces the emissions from landfills, while also reducing the consumption of fossil fuels like diesel and coal, which produce much higher particulate and greenhouse gases than natural gas. Waste Management operates more than 100 natural gas fueling stations, and produces landfill gas at over 130 facilities.

The company's efforts aren't just good for the environment, either; they're also good business. The company produced $856 million in operating cash flows in its most-recent quarter, up 13% from last year and its most ever in a single quarter. And it's likely that cash flows will continue to trend upwards.

Further, since its services are necessary no matter the economic environment, Waste Management is an ideal recession-resistant investment, and a solid dividend growth stock. If you want stability and income growth from a company with serious green bona fides, Waste Management belongs in your portfolio.

Building a greener outdoor life

Homeowners often want to make the most of their outdoor space, and in many cases, that means having nice deck. The downside is that they can take a lot of work: annual pressure washing and cleaning, staining, and water treatment with chemicals that may not be very good for the environment. And if you skip a few years of waterproofing or staining, you may need to spend thousands of dollars to replace decking that's literally falling apart beneath your feet.

This is where Trex comes in. As the leading supplier of wood-alternative decking, the company commands 45% of annual sales in North America, and has been steadily growing its market share for years. And, as the table at the top of this article shows, it has made Trex a wonderful investment, with shares up almost 430% over the past five years.

Trex has plenty of room to grow, too, because when you include real wood decking, Trex's total market share is less than 8% of linear board-feet sold each year. That's a huge amount of the market that's not using Trex products today. And with more young families taking the step into homeownership for the first time, the company's prospects to keep taking share from wood are very, very good.

Trex's decking is made from 100% recycled plastic and wood shavings, while a traditional wooden deck is made from newly felled virgin timber. Trex products also doesn't require the fresh coats of chemical sealers and stains that wood decking needs every year, and will still last decades longer than a wood deck, further increasing the environmental -- and financial -- benefits of choosing them. Those attractions are only likely to grow more compelling, resulting in rising market share and higher profits, while also cutting carbon emissions related to the timber industry.

Combined, that all makes Trex a great stock for the environment and for your portfolio.

Being green helps Nucor make more green

Simply put, it takes a lot of energy to turn iron and other raw materials into steel, then shape that steel into the many products it becomes. Because of that, it really shouldn't come as a surprise that Nucor, America's biggest steelmaker, invests heavily in green initiatives designed to cut its power consumption, increase recycling, and keep as much of what comes through its factories out of landfills as it can. After all, every dollar it doesn't have to spend on power or waste removal adds to its bottom line.

To start, Nucor is the largest recycler in North America. Instead of relying mainly on freshly-mined iron to feed its mills, Nucor's electric arc furnaces (EAF) use steel scrap as their primary raw material. Not only does this help reduce the environmental impact of the iron mining that would be needed to replace that steel, but also massively reduces energy consumption. Nucor's EAFs consume around 1,700 fewer kilowatt hours of electricity than a traditional blast furnace per ton of steel produced. That works out to a remarkable 2 million tons in reduced pollutants every year versus traditional blast furnaces still used by many steelmakers. And that's just the power consumption savings.

Nucor has also pioneered other green initiatives in steelmaking, such as recycling the vast majority of the byproducts from its mills. Not only does this keep those materials out of landfills, but the company says it helps reduce air pollution by keeping the trucks that would have had to transport those materials to landfills off the road, as well as offsetting the amount of mining required to produce rare metals like zinc, which are recycled from Nucor's waste products.

Add it all up, and Nucor's relentless focus on recycling and energy consumption has made it a better steward of the environment while also helping its bottom line. It's more affected by the ups and downs of the economy than Waste Management, but it's also a solid income and growth stock for long-term investors who are comfortable riding out the occasional market downturn. Nucor is the undisputed environmental leader in steelmaking, but also the most consistently profitable, and is coming off its best year in almost a decade. Green investors should give it a close look.