The new inflation numbers that just dropped certainly have the markets worried about the depth of the recession we could be facing. With the S&P 500 index firmly in bear market territory, down 25% year-to-date, investors are rightly nervous about what it means for stocks.

Yet, history shows that bull markets always follow these corrections. And whereas bear markets are measured in months, bull markets are measured in years. That means sharp downturns are actually the best time to buy stocks for the long-term returns generated for your portfolio.

Man holding groceries surprised by prices.

Image source: Getty Images.

As Warren Buffett once said, be fearful when others are greedy, and greedy when others are fearful. As long as investors have an appropriate investment horizon -- 10 years is usually good -- they should not fear bear markets, but look forward to them eagerly as a chance to buy good companies at discounted prices.

If you have $5,000 available, the following two growth stocks are excellent companies to own for years to come.

Apple

Apple (AAPL 0.02%) stock is down 22% in 2022 as investors worry about the economy's impact on consumer spending habits. It's estimated that App Store sales fell 5% in September, their biggest decline ever, and they are down 2% for the quarter. While that creates near-term headwinds, there is still strong demand for higher-priced iPhone 14 models, and a Piper Sandler survey of teens says Apple's share of the smartphone market remains near record highs.

One short-term catalyst is Apple's $90 million stock buyback program, which should help support any earnings weakness. And over the long haul Apple continues striving to  introduce new products, such as virtual reality headsets and the long-awaited Apple Car, which it would like to bring to market by 2025.

While some services like the App Store may see lower revenue in the coming quarters, others like iCloud, AppleCare, and even music ought to keep growing. Product sales are stable too, and because Apple has been able to keep its premium pricing intact as demand maintains its upward trajectory, the macroeconomic pressures on the company won't be as great as they will be on its lower-end rivals.

Investors might also take comfort in knowing that buying Apple stock at these prices means they will be buying the tech giant at prices cheaper than Warren Buffett got when he made the company 41% of Berkshire Hathaway's (NYSE: BRK.A)(NYSE: BRK.B) portfolio.

Costco

Another stock buffeted by consumer spending worries is Costco (COST 0.34%), whose stock is down 18% this year, and fell again last month despite reporting financial results that beat Wall Street expectations.

Inflation is taking its toll, with September's numbers coming in hotter than expected. Particularly in the pocketbook items that matter most to consumers -- food and fuel -- inflation is even higher than the headline print. Utility gas is up 33% over last year, eggs are 30% higher, gas prices are up 18%, chicken 17%, coffee and milk 15% higher, and so on.

Costco has chosen not to raise its membership fees at this time, much to the consternation of some, but that is actually helping drive shoppers to its warehouse clubs and helping to grow sales by double-digit rates. Comparable store sales growth dipped to 8.5% in September, the first time in 28 months they were below 10% (they were still up over 11% in the U.S.). It proves bulk buying of goods is a smart choice in this high-cost period, even if it doesn't fully insulate the retailer from the ravages of inflation. Gross margins, for example, were 10.5%, down from 11.1%, in fiscal 2021.

However, memberships remain a source of strength for Costco, and consumers are still flocking to the warehouse club. It ended its fiscal fourth quarter last month with 118.9 million cardholders, of which 53.1 million were household members, up 6.5% from last year.

While the economy can always get worse, Costco's results show the soundness and stability of its business model. It should carry the retailer through the tough times, which makes its stock a solid choice for an investor willing to buy and hold for the long haul.