Quote:
Originally Posted by Insanebot Pls puys temme wot dis mod method is
pls! |
let me have the oppurtunity to answer your question. take a look at this:
find the remainder when 2^21 is divided by 5?
write 2^21 in a a way which is simpler to be divided by 5.
let me write it as:
8^7
Now on dividing 8 by 5 gives 3 as remainder (the so called mod operation) which means that on dividing 8^7 will give me 3^7 as remainder (3 from each of the8's)
let me write 3^7 as:
9*9*9*3
when 9 is divided by 5, the remiander is 4 (the result of mod operation is 4) and hence when (9^3)*3 is divided by 5, the remainder is:
(4^3)*3 = 16*4*3 = 1*12 = 1*2 = 2 (do you notice what operation I am applying here?)
hence the remainder when 2^21 is divided by 5 is 2.
cross check by dividing 2097152 by 5.
The beauty of mod operation is that the better you split your original expression, the lesser the time it takes to find the solution. e.g. if instead I had split 2^21 as
128^3. I would have gone like this:
2^21=128^3=3^3=27=2 (mod operation is being apllied at each step)
hope i have made some base. the more you practice, the better(faster) will be the results.