# Need help finding the flaw to the proof that $(a+b)\mathrm {mod} m = a\mathrm {mod} m + b \mathrm {mod} m$ [duplicate]

Let $a,b \in \mathbb {Z}$ and let $m$ be an integer greater than $2$. I found a counterexample to the equation

$$(a+b)\mathrm {mod} m = a\mathrm {mod} m + b \mathrm {mod} m$$

where $m>2$. But that was only after I thought I had proven that the equation does hold, so I was wondering if someone could point out to me where the flaw is in the following.

If we divide $a$ and $b$ by $m$, then we have by the division algorithm

$$a=mc+x$$ $$b=md+y$$

$$a+b=me+(x+y)$$

And since $a\mathrm {mod} m + b \mathrm {mod} m= x+y$, then from the third equation, it seemes that the proposition holds.

## marked as duplicate by Bill Dubuque elementary-number-theory StackExchange.ready(function() { if (StackExchange.options.isMobile) return; $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() { var$hover = $(this).addClass('hover-bound'),$msg = $hover.siblings('.dupe-hammer-message');$hover.hover( function() { $hover.showInfoMessage('', { messageElement:$msg.clone().show(), transient: false, position: { my: 'bottom left', at: 'top center', offsetTop: -7 }, dismissable: false, relativeToBody: true }); }, function() { StackExchange.helpers.removeMessages(); } ); }); }); Nov 25 '16 at 23:24

• What if $x+y$ is greater than $m$? – Michael Burr Nov 25 '16 at 23:14
• You can seperate it, but you need to mod the result. $a+b\mod m=(a\mod m+b\mod m)\mod m$. – AlgorithmsX Nov 25 '16 at 23:18

$a\mod m+b\mod m=x+y$
Suppose $x=m-1$ and $y = m-1$
$x+y = 2m-2$
$a\mod m+b\mod m$
would actaully be $m-2$.
Actually, the formula should be $$(a+b)\bmod m\equiv (a\bmod m+b\bmod m)\bmod m.$$ That's why computing in the ring $\mathbf Z/m\mathbf Z$ is simpler than computing with congruence classes in $\mathbf Z$.