N-bit ripple-carry mod adder passes doctest after some very painful debugging.