The TeX Catalogue OnLine, Entry for longdiv, Ctan Edition

Long division arithmetic problems.

Work out and print integer long division problems. Use: \longdiv{numerator}{denominator}. The numerator and denominator (divisor and dividend) must be integers, and the quotient is an integer too. \longdiv leaves the remainder from the division at the bottom of its diagram of the problem.