Saturday, 25 January 2014

elementary number theory - How do I compute ab,bmodc by hand?



How do I efficiently compute abmodc:





  • When b is huge, for instance 5844325mod21?

  • When b is less than c but it would still be a lot of work to multiply a by itself b times, for instance 569mod101?

  • When (a,c)1, for instance 6103mod14?



Are there any other tricks for evaluating exponents in modular arithmetic?






This is being asked in an effort to cut down on duplicates, see here: Coping with *abstract* duplicate questions.




and here: List of Generalizations of Common Questions


Answer



Wikipage on modular arithmetic is not bad.




  • When b is huge, and a and c are coprime, Euler's theorem applies:
    ababmodϕ(c)modc



    For the example at hand, ϕ(21)=ϕ(3)×ϕ(7)=2×6=12. 844325mod12=5, so 55=5×2525×42=8017mod21.


  • When a and c are coprime, but $0545×535×2419(mod101)194(192)2582(43)2184931(mod101)314(312)2(961)2522270478(mod101)5695×54×((54)4)45×19×785×19×(23)19×(14)26637(mod101)


  • When a and c are not coprime, let g=gcd(a,c). Let a=g×d and c=g×f, then, assuming b>1:
    abmodc=gb×dbmod(g×f)=(g×(gb1dbmodf))modc


    In the example given, gcd(6,14)=2. So 2102×3103mod7, using Euler'r theorem, with ϕ(7)=6, and 1020mod6, 2102×31033mod7, so 6103(2×3)6mod14.



No comments:

Post a Comment

real analysis - How to find limhrightarrow0fracsin(ha)h

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