He was once known as the “Wizard of Wall Street,” but Ponzi villain Bernie Madoff couldn’t handle long division.

A former supervisory trader for Madoff who pleaded guilty to fraud charges told a jury Thursday that his imprisoned-for-life ex-boss was in serious need of math tutoring — even while pulling off the biggest investment scam in history.

Cooperating government witness David Kugel testified in Manhattan federal court that shortly after he was hired in the early 1970s to trade convertible bonds, Madoff solicited his help in determining the rates of return for similar deals the crook was cutting with private clients.

“He asked me to do the math to calculate the returns,” said Kugel, 68.

Assistant US Attorney Matthew Schwartz then asked if Madoff was “good in math.”

To that, Kugel deadpanned, “In some aspects, yes, in some aspects, no. He had trouble with long division.”

Kugel, the government’s first key witness in a trial of five ex-Madoff staffers accused of profiting from the decades-long fraud, testified how he provided defendants Annette Bongiorno and Joann Crupi phony trading data for customer accounts.

Kugel said he suspected something was wrong at Madoff Securities in the early 1970s when Bongiorno, who was Madoff’s secretary, began asking him for outdated pricing data, adding that she kept old issues of The Wall Street Journal at her desk so they could look up historical prices to help “fabricate” trades. He said he supplied the same type of information for Crupi in the late 1980s and early 1990s.

Kugel said his suspicions were finally confirmed in 1977 when he opened his own personal investment account with the company — with $25,000 from the sale of his father-in-law’s house — and discovered that backdated trades he created appeared on his own statements.

“It was at that time that I knew the trade information I was giving them was being fabricated,” he said.

Kugel, however, claimed that he never suspected a Ponzi scheme was going on. He said he confronted Madoff about where the money was really going — if it wasn’t being invested in securities — and that Madoff said he was putting it in shopping centers, foreign currency and other investments.

“He was my boss, and he asked me to do something,” Kugel said. “I knew it was wrong, but I just didn’t question him.”

Kugel said Madoff eventually allowed him to even pick backdated trades for his personal account, which at one time grew to $10 million.

Kugel pleaded guilty in November 2011 to boosting the fraud by creating phony backdated trades beginning in the early 1970s and continuing until Madoff’s empire was busted by the feds in December 2008.

His son, Craig Kugel, who worked in human resources for Madoff, has also pleaded guilty to participating in the scheme.

Besides Bongiorno and Crupi, also on trial are former Madoff operations chief Daniel Bonventre and computer programmers George Perez and Jerome O’Hara.

Kugel will continue on the stand Monday when the case returns to court.