VERSION|0.4.7.1|SUBJECT|Distributivity of multiplication over modulo|CONTENT|[html]
&lt;h6&gt;Theorem&lt;/h6&gt;
&lt;p&gt;
&lt;b&gt;Given:&lt;/b&gt; Integers a, b, c, such that:
&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;a &amp;gt;= 0&lt;/li&gt;
&lt;li&gt;b &amp;gt; 0&lt;/li&gt;
&lt;li&gt;c &amp;gt; 0&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
&lt;b&gt;Given:&lt;/b&gt; % represents modulo operator
&lt;/p&gt;

&lt;p&gt;
&lt;b&gt;Theorem:&lt;/b&gt;
(a % b) × c == (a×c) % (b×c)
&lt;/p&gt;

&lt;hr /&gt;

&lt;h6&gt;Proof Part A:&lt;/h6&gt;
&lt;p&gt;
First I will define a new formula for modulo that uses subtraction,
multiplication, and the floor() function.
&lt;/p&gt;

&lt;p&gt;
&lt;b&gt;Given:&lt;/b&gt; floor(x/y) represents the integer part of the division of x and y.
&lt;/p&gt;

&lt;table cellspacing=&quot;1&quot; cellpadding=&quot;4&quot; border=&quot;1&quot;&gt;
&lt;tr&gt;
	&lt;td&gt;1.&lt;/td&gt;
	&lt;td&gt;(x % y)&lt;/td&gt;
	&lt;td&gt;Given: x Modulo y&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
	&lt;td&gt;2.&lt;/td&gt;
	&lt;td&gt;[x/y - floor(x/y)] × y&lt;/td&gt;
	&lt;td&gt;Divide x and y, subtract the integer part, then multiply by the divisor to get the remainder&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
	&lt;td&gt;3.&lt;/td&gt;
	&lt;td&gt;x - y × floor(x/y)&lt;/td&gt;
	&lt;td&gt;Distribute multiplication over subtraction&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;

&lt;p&gt;
I didn&#039;t really prove how to go from step 1 to step 2, but it is pretty easy to reason about.&lt;br /&gt;
In any case, here is &lt;a href=&quot;http://en.wikipedia.org/wiki/Modulo_operation&quot;&gt;another page&lt;/a&gt; that comes up with the same formula.
&lt;/p&gt;

&lt;h6&gt;Proof Part B:&lt;/h6&gt;
&lt;p&gt;
Here comes the fun proof. I will prove the theorem by simplifying the equation
one step at a time.
&lt;/p&gt;

&lt;table cellspacing=&quot;1&quot; cellpadding=&quot;4&quot; border=&quot;1&quot;&gt;
&lt;tr&gt;
	&lt;td&gt;1.&lt;/td&gt;
	&lt;td&gt;(a % b) × c&lt;/td&gt;
	&lt;td&gt;=?=&lt;/td&gt;
	&lt;td&gt;(a×c) % (b×c)&lt;/td&gt;
	&lt;td&gt;Given: The theorem we are trying to prove&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
	&lt;td&gt;2.&lt;/td&gt;
	&lt;td&gt;(a % b) × c&lt;/td&gt;
	&lt;td&gt;=?=&lt;/td&gt;
	&lt;td&gt;ca % cb&lt;/td&gt;
	&lt;td&gt;Simplify right side and reverse order of multiplication&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
	&lt;td&gt;3.&lt;/td&gt;
	&lt;td&gt;[a - b × floor(a/b)] × c&lt;/td&gt;
	&lt;td&gt;=?=&lt;/td&gt;
	&lt;td&gt;ca - cb × floor[(ca)/(cb)]&lt;/td&gt;
	&lt;td&gt;Replace modulo operator with formula in step 3 of Proof Part A&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
	&lt;td&gt;4.&lt;/td&gt;
	&lt;td&gt;ca - cb × floor(a/b)&lt;/td&gt;
	&lt;td&gt;=?=&lt;/td&gt;
	&lt;td&gt;ca - cb × floor[(ca)/(cb)]&lt;/td&gt;
	&lt;td&gt;Distribute multiplication over subtraction&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
	&lt;td&gt;5.&lt;/td&gt;
	&lt;td&gt;-cb × floor(a/b)&lt;/td&gt;
	&lt;td&gt;=?=&lt;/td&gt;
	&lt;td&gt;-cb × floor[(ca)/(cb)]&lt;/td&gt;
	&lt;td&gt;Subtract c×a from both sides&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
	&lt;td&gt;6.&lt;/td&gt;
	&lt;td&gt;floor(a/b)&lt;/td&gt;
	&lt;td&gt;=?=&lt;/td&gt;
	&lt;td&gt;floor[(ca)/(cb)]&lt;/td&gt;
	&lt;td&gt;Divide both sides with -c×b&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
	&lt;td&gt;7.&lt;/td&gt;
	&lt;td&gt;floor(a/b)&lt;/td&gt;
	&lt;td&gt;==&lt;/td&gt;
	&lt;td&gt;floor(a/b)&lt;/td&gt;
	&lt;td&gt;The c&#039;s divide out.&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
[/html]|CATEGORIES|2|DATE|1140678000
