Beth ordered a chocolate from a factory with A x B size. After receiving the chocolate, she ordered her assistant to cut it into square cubes, with the least possible cuts required.
Her assistant then turned into a mathematician to find the answer. She ended up having the least possible slices and got a thanks from Beth.
What was the mathematician's answer to the assistant?