A furor over slavery has erupted at a Midtown elementary school, after a teacher handed out math homework that include questions asking kids to tally the killing and beating of slaves.

The shocking questions were given to at least one class of 9-year-olds at PS 59 in Manhattan — which included the kids of United Nations personnel. The inflammatory queries were only uncovered after a student teacher was asked to hand them out to a second class.

“What a shock! It seems so over the top,” said NYU professor Charlton McIlwain, who instructed the student teacher, Aziza Harding, that spotted the offensive questions.

Education officials said the trouble arose from a clumsy attempt by teacher Jane Youn to meld a history lesson on slavery with an assignment in math.

She asked the students to create their own questions, and distributed them as homework last month with the slave questions included, officials said.

One of the questions reads: “One slave got whipped five times a day. How many times did he get whipped in a month (31 days)?”

A separate subtraction question says: “In a slave ship, there can be 3,799 slaves. One day, the slaves took over the ship. 1,897 are dead. How many slaves are alive?”

The same worksheet was nearly assigned to teacher Jacqueline Vitucci’s class when she went on vacation this month. But Harding — her student teacher — put the kibosh on it before the papers were distributed.

“This is obviously unacceptable and we will take appropriate disciplinary action against these teachers,” said a DOE spokeswoman. “The Chancellor spoke to the principal, and she has already taken steps to ensure this does not happen again.”

Longtime principal Adele Schroeter said she was “appalled.”

“I have already met with the teacher and have arranged for training around this issue ,” she said in a statement.

A message left at a number listed for Youn was not returned.

In a strikingly similar case, third graders at a school in Norcross, Ga. were given homework last year where they had to calculate how many times slaves were beaten.

The teacher who gave that assignment later resigned.