How Does Repeated Squaring Simplify Calculating Powers Modulo a Number?

  • Thread starter Thread starter ArcanaNoir
  • Start date Start date
Click For Summary

Homework Help Overview

The discussion revolves around calculating \( 2^{644} \mod 645 \) using repeated squaring and exploring related number theory concepts such as Euler's theorem and Fermat's little theorem.

Discussion Character

  • Mixed

Approaches and Questions Raised

  • Participants discuss the use of repeated squaring and express confusion about its application. Some suggest alternative theorems like Euler's theorem and Fermat's little theorem, while others explore the implications of the cyclic nature of powers modulo 645.

Discussion Status

There is an ongoing exploration of different methods and theorems, with participants sharing insights and questioning the effectiveness of repeated squaring. Some guidance has been provided regarding the use of Euler's theorem, but there is no explicit consensus on the best approach yet.

Contextual Notes

Participants note the complexity of calculating powers modulo a composite number and the challenges posed by the specific properties of the numbers involved, such as the non-primitive nature of 2 with respect to 645.

ArcanaNoir
Messages
778
Reaction score
4

Homework Statement


Calculate 2^{644} mod 645.

Homework Equations



I think I should use repeated squaring, but I'm open to other techniques.

The Attempt at a Solution



I start out fine,
2=2 \\<br /> 2^2=4\\<br /> 2^4= 16\\<br /> 2^8=256\\<br /> 2^{16}=65536\equiv 391
But that's where it starts to break down. I don't think I understand the point of repeated squaring. I mean yes I know I am looking for 256+256+128+4 =644 but that requires calculating 2^256 mod 645, which is still stupidly difficult as far as I can tell, or is there something I'm missing?
 
Physics news on Phys.org
That looks to me like some variation on Fermat's little theorem should work.
 
Yeah.. Probably, but what?
 
If you're not going to use some special theorem, just continue, but then you run into a cyclic pattern at 2^28 because 2 is not a "primitive" of 645 (since 645 = 3 * 5 * 43, it isn't prime and I don't think there is a "primitive"):

<br /> 2^{16} | 645 = 391 \\<br /> 2^{32} | 645 = 391^2 | 645 = 16 \\<br /> 2^{28} | 645 = 1 \\<br /> 2^{29} | 645 = 2 \\<br /> 2^{30} | 645 = 4 \\<br /> 2^{31} | 645 = 8 \\<br /> 2^{32} | 645 = 16 \\<br /> 2^{56} | 645 = 1 \\<br /> 2^{n*28} | 645 = 1<br />
For that last one, n can be any integer.
 
Last edited:
Use the very most elementary property of 2 that you know.

And I expect you know the binomial theorem.

:wink:

Then I think it is not too difficult.
 
Hey Arcana!

Euler's theorem says that ##a^{\phi(n)} \equiv 1 \pmod n## if a and n are relatively prime.
Since 2 and 645 are relatively prime and ##\phi(645) = \phi(3 \cdot 5 \cdot 43) = (3-1) \cdot (5-1) \cdot (43-1) = 336##, we get that:
$$2^{336} \equiv 1 \pmod {645}$$
Can you use that to help simplify the expression?
(If you have more problems like this, we'll soon get to the Chinese Remainder Theorem! :cool:)
 
Thanks for all the help guys! I think rcgldr wins, with 2^28*n since I think I've used that kind of logic before. This doesn't really solve my question about the method of repeated squaring itself though, as 28 wouldn't have been in the sequence, but it wouldn't be the first time we learned a crappy method to calculate something (crappy by hand, cheaper by computer). I really don't like my number theory class..

ILS, we did the Chinese remainder theorem on the last exam. :)

What was epenguin implying about the binomial theorem?
 
ArcanaNoir said:
Thanks for all the help guys! I think rcgldr wins, with 2^28*n since I think I've used that kind of logic before. This doesn't really solve my question about the method of repeated squaring itself though, as 28 wouldn't have been in the sequence.
2^28 wouldn't have been in the repeated squaring sequence, but you eventually run into ((2^32) | 645)) = 16, indicating that the sequence had cycled, and if ((2^32) | 645)) = 16 = ((2^4) | 645)), then it would be expected for ((2^28) | 645)) = 1. For this case, ((2^((28*n) + m)) | 645)) = ((2^m) | 645)), where n and m are any integers.
 
Last edited:
  • #10
Thanks rcgldr, that's very helpful :)
 
  • #11
ArcanaNoir said:
Thanks for all the help guys! I think rcgldr wins, with 2^28*n

Aww, I really wanted to win!
Although I have to admit that rcgldr, showing what the order of 2 is, did a good job. :wink:
 
  • #12
A late follow up on this, but instead of repeated squaring of 2 mod 645, it could be repeated squaring of 3 mod 929. 929 is a prime number, and 3 is a "primitive" of 929, and every number from 1 to 928 will end up being some power of 3 mod 929.

The point of this is getting back to your original question, rather than calculaing 3^928 as a huge number, then taking the modulus of that huge number, you can perform all of the math modulo 929:

3^0 mod 929 = 1
3^1 mod 929 = 3
3^2 mod 929 = 9
3^4 mod 929 = 9^2 mod 929 = 81
3^8 mod 929 = 81^2 mod 929 = 58
3^16 mod 929 = 58^2 mod 929 = 577
3^32 mod 929 = 577^2 mod 929 = 347
3^64 mod 929 = 347^2 mod 929 = 568
3^128 mod 929 = 568^2 mod 929 = 261
3^256 mod 929 = 261^2 mod 929 = 304
3^512 mod 929 = 304^2 mod 929 = 445
3^768 mod 929 = 3^(512+256) mod 929 = 445 x 304 mod 929 = 575
3^896 mod 929 = 3^(768+128) mod 929 = 575 x 261 mod 929 = 506
3^928 mod 929 = 3^(896+32) mod 929 = 506 x 347 mod 929 = 1
 
Last edited:

Similar threads

Replies
7
Views
2K
  • · Replies 7 ·
Replies
7
Views
2K
Replies
14
Views
5K
  • · Replies 4 ·
Replies
4
Views
2K
Replies
9
Views
3K
  • · Replies 14 ·
Replies
14
Views
2K
Replies
39
Views
6K
Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 6 ·
Replies
6
Views
3K