Barack Obama is trying to take credit for the booming economy under President Trump. “When you hear how great the economy is doing right now,” Obama said on the campaign trail for Democratic candidates a few days ago, “let’s just remember when this recovery started.”

By this logic, the Kingston Trio laid the groundwork for the Beatles.

But the contrast in economic performance between the two presidents is undeniable. Obama’s multitrillion-dollar spend-and-borrow policies produced 2 percent growth. In his final year, Obama handed off to Trump an economy that was limping at 1.6 percent.

After only 18 months in office, Trump has elevated growth to 3 percent on an annual rate and the latest projections are that the growth rate for the second and third quarter (which ends Sept. 30) will be over 4 percent. One might say all it took to get the economy really crackling was getting Obama out of office.

Obama is right that this has been a long recovery — beginning in June 2009. But the real economic boom started almost the day after the election in 2016 with the surge in small business, investor and consumer confidence.

No one on the left, least of all Obama, thought this was remotely possible.

Two years ago, Obama famously ridiculed Trump’s campaign promise of faster growth and a comeback in manufacturing jobs by saying this could only happen if Trump was waving “a magic wand.” Obama’s first chief economist, Larry Summers, proclaimed to the world that 2 percent was the best we could hope for. Other liberal economists were so disdainful of Trump’s tax cuts, deregulation and energy development that they predicted Trump would crash the world economy and the stock market.

It’s a little early to be declaring Trump’s policies a “miracle,” as Trump has boasted. All we can say is whatever he’s doing, it’s working.

And that Obama’s economic experiment of Keynesian economics on steroids was a profound disappointment. It began with the $830 billion stimulus plan, and then cash-for-clunkers, bailouts, ObamaCare, tax hikes on the rich, minimum-wage hikes and a wave of financial and economic regulations. All told, the national debt nearly doubled in eight years.

Meanwhile, the Obama recovery was remarkably flimsy. In 2015, the Joint Economic Committee of Congress found that compared to the eight previous post-recession events, “the Obama recovery was the weakest on record.”

The recovery was so shallow that had Obama merely achieved a normal pace of recovery, personal income in 2014 would have been $3,200 higher. If the economy had matched the Reagan trajectory, GDP in 2016 would have been almost $3 trillion larger (equivalent to the combined GDP of Michigan, Ohio and Pennsylvania).

Even as measured by the left’s favorite metric, “economic fairness,” the policies failed. The index of income inequality rose nearly every year under Obama.

While Silicon Valley, Hollywood, Washington, DC, Wall Street and the energy states did spectacularly well (thanks to shale oil and gas), in the Rust Belt regions of the country — from upstate New York to Ohio and Wisconsin, West Virginia and Kentucky — family incomes remained flat at best. On the campaign trail, I often asked folks in small towns across the Midwest about the Obama recovery, and their response was: What recovery?

Trump didn’t just run against Hillary Clinton and her closet overflowing with scandals, but the meager Obama economy as well. He ran against the runaway costs of ObamaCare. He ran against the regulatory assault, the tax hikes, unpopular trade deals and climate-change fanaticism. He ran against hopelessness, against opioid addiction, the $10 trillion rise in the national debt and income stagnation.

One time during the campaign, Larry Kudlow, Steve Miller and I held an impromptu discussion with Trump about economic strategy. Miller summarized the game plan to Trump succinctly: “Donald, just look at all the things that Obama has done on the economy over the past eight years, and then do just the opposite.”

Trump has done pretty much just that — which explains why the Trump boom is an everyday reminder of the Obamanomics failure.

Stephen Moore is a senior fellow at the Heritage Foundation and a former senior economic adviser to the Trump campaign. His new book, “Trumponomics,” will be published next month.