Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

It's from a programming language. "%' here is a modulo operation.

(a * 2^32 + b) % c = (((a % c) * (2^32 % c)) + b) % c
share|improve this question
    
So, what you want to prove is that $a\cdot b(\mod c)=(a(\mod c)\cdot b(\mod c))(\mod c)$ and the same holds for addition, correct? –  Dennis Gulko Nov 13 '12 at 10:14
    
Mmm, probably right :) But I'm not a mathematician, so I would be glad to take a look at some basic articles on this theme. –  accme Nov 13 '12 at 10:32
add comment

1 Answer 1

In general, if you have two integers

a = j + kc
b = l + mc

Then

ab % c
= (j+kc)(l+mc) % c 
= (jl + jmc + lkc + kmc^2) % c
= jl
= (a % c)(b % c)
share|improve this answer
    
And the same for sums. –  Fabian Nov 13 '12 at 10:20
    
"jl + jmc + lkc + kmc^2 % c" - does '%' relate only to the last term? Why? And why this equals to 'jl'? –  accme Nov 13 '12 at 10:27
    
Just like (1+2+4+6)/2=(1/2)+1+2+3 (look at the parentheses), (jl + jmc + lkc + kmc^2) / c=(jl/c)+jm+lk+kmc. Think about what that means about (jl + jmc + lkc + kmc^2) % c. –  Mark S. Nov 13 '12 at 12:32
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.