I know there are other such topics but I really can't figure how to calculate the following equation: 2^731 mod 645.
Obviously I can't use the little theorem of Fermat since 645 is not a prime number and I can't also do the step by step rising of powers(multiplying by 2) since the numbers are still really big. Is there any way to do calculate the result in a normal way (without the enormous numbers) ? Thanks in advance!
How to calculate modulo of high power of 2
-
3Have you heard about Euler's theorem? – 2017-01-27
3 Answers
$645 = 15\cdot 43\,$ so we can compute $\,2^{\large 731}\!$ mod $15$ and $43,\,$ then combine them (by CRT or lcm).
${\rm mod}\ 15\!:\,\ 2^{\large\color{#c00} 4}\equiv 1\,\Rightarrow\, 2^{\large{731}}\equiv 2^{\large 3}\,$ by $\,731\equiv 3\pmod{\!\color{#c00}4}$
${\rm mod}\ 43\!:\,\ 2^{\large 7}\equiv -1\,\Rightarrow\,2^{\large\color{#c00}{14}}\equiv 1$ so $\,2^{\large 731}\equiv 2^{\large 3}\,$ by $\,731\equiv 3\pmod{\!\color{#c00}{14}}$
So $2^{\large 731}\!-2^{\large 3}$ is divisible by $15,43\,$ so also by their lcm = product $= 645,\,$ i.e. $\,2^{\large 731}\!\equiv 2^{\large 3}\!\pmod{\!645}$
-
0Thanks for the response. I have tried to use the same strategy for another large calculation 1503^2459 mod 3149 and I got stuck again... I don't want to open another topic for this since my question is closely related to the one here so can you share if there is another strategy for dealing with this case or I don't use the method you shared above correctly? Thanks ! – 2017-01-31
-
0@devole Use $\ 3149 = 47\cdot67,\ 1503\equiv -1\pmod{47},\,$ and ${\rm mod}\ 67\!:\ 1503\equiv 29,\ 29^3\equiv 1.\ \ $ – 2017-02-01
A commenter mentioned Euler's theorem, which could be useful; but another approach presents itself: successive squaring. Recall that if $a \equiv b \mod c$, then $a^2 \equiv b^2 \mod c$. For example, $2^2 \equiv 4 \mod 645$, $4^2 \equiv 16 \mod 645$, $16^2 \equiv 256 \mod 645$, $256^2 \equiv 391 \mod 645$, and $391^2 \equiv 16 \mod 645$. So we know that $2^{32} = 2^{2^5} \equiv 16 \mod 645$. Now we can keep squaring: $2^{64} = 2^{2^6} = (2^{2^5})^2 \equiv 256 \mod 645$, $2^{128} = 2^{2^{7}} \equiv 391 \mod 645$, $2^{256} \equiv 16 \mod 645$, and $2^{512} \equiv 256 \mod 645$.
We can write $2^{731}$ as $2^{512}2^{219} = 2^{512}2^{128}2^{91} = 2^{512}2^{128}2^{64}2^{16}2^{8}2^22^1$. Modulo $645$, this is therefore $256 \cdot 391 \cdot 256 \cdot 391 \cdot 256 \cdot 4 \cdot 2$. Still pretty big, but remember that we already know that $256^2 \equiv 391 \mod 645$ and $391^2 \equiv 16 \mod 645$, so now we have $391 \cdot 256 \cdot 16 \cdot 4 \cdot 2$. $391 \cdot 256 \equiv 121 \mod 645$. $121 \cdot 16 \equiv 1 \mod 645$. $1 \cdot 4 \cdot 2 \equiv 8 \mod 645$. So our final answer is that $2^{731} \equiv 8 \mod 645$.
We can also do variations on this using successive cubing, or other powers; it's sort of a matter of preference.
$645=3\cdot 5\cdot 43$
$2^{731}\equiv -1^{731}\equiv -1 \equiv 2 \equiv (2+3+3) \equiv 8 \pmod {3}$
$\implies \left(2^{731}-8\right) \equiv 0 \pmod 3$
$2^{731}=2.2^{730}=2.4^{365}\equiv 2 \times -1^{365} \equiv -2 \equiv 3 \equiv (3+5) \equiv 8\pmod {5}$
$\implies \left(2^{731}-8\right) \equiv 0 \pmod 5$
$2^{731}=8^.\left(2^{7}\right)^{104}\equiv 8 \times -1^{104} \equiv 8\pmod {43}$
$\implies \left(2^{731}-8\right) \equiv 0 \pmod {43}$
Therefore,
$\left(2^{731}-8\right) \equiv 0 \pmod {LCM(3,5,43)}$
$\implies \left(2^{731}-8\right) \equiv 0 \pmod {645}$
$\implies 2^{731} \equiv 8 \pmod {645}$
-
0Same as my answer except you split $15,\,$ making it more work. – 2017-01-27
-
0infact i was referring to your answer given for a similar question (not this one) in this site while writing my answer :). there you had used CRT and i was trying to write with LCM. noticed your post after posting my answer. – 2017-01-27
-
1That's funny. Usually I tend to use LCM's when they suffice, but I try to factor in what they OP may (or may not) know when making the choice. – 2017-01-27