Penso che tu abbia avuto un attimo di cortocircuito

345/123 = 2.8....

Resto = 345-123*(ParteIntera(345/123)) = 345 - 123*2 = 99;