Sunday, 20 October 2013

elementary number theory - mod cancellation: compute ,n/2bmod6, from ,nbmodm, for even n



I am using the C++ language.
I want to calculate these 2 expressions:-



In our case, x=100000000000000000




Expression(1)



((3^x-1)/2)\mod7



The numerator 3^x-1 is always divisible by 2(basic number theory)



I calculated the above expression using Extended-Euclid-Gcd algorithm.
The above algorithm only works when gcd(denominator,mod-value)=1...in our case \gcd(2,7)=1 . So we were able to calculate it using the above algorithm.



Expression(2)




((3^x-1)/2)\mod6



The numerator 3^x-1 is always divisible by 2(basic number theory-again)



Now, how do I calculate the above expression as \gcd(2,6)=2 which is not equal to 1 ?


Answer



Set
y = \frac{3^x - 1}{2}.




Let 0 \leq b < 6 such that y = 6a + b for some integer a. Then
2y = 12a + 2b
and 0 \leq 2b < 12, so you could simply compute 3^x - 1 \mod{12}.


No comments:

Post a Comment

real analysis - How to find lim_{hrightarrow 0}frac{sin(ha)}{h}

How to find \lim_{h\rightarrow 0}\frac{\sin(ha)}{h} without lhopital rule? I know when I use lhopital I easy get $$ \lim_{h\rightarrow 0}...