Solve n mod m