mersenneforum.org  

Go Back   mersenneforum.org > Great Internet Mersenne Prime Search > Math

Reply
 
Thread Tools
Old 2004-07-02, 13:18   #1
jfollas
 
Jul 2004

11102 Posts
Default Raising numbers to a power of two

Are there any shortcuts for raising a number to a power of two (modulo a mersenne)?

Examples:

37^1024 (mod 127)

65^2048 (mod 8191)

I realize that the exponential operation using the binary method takes P iterations (for the power 2^P).

Example:

37^1024 = ((((((((((37^2)^2)^2)^2)^2)^2)^2)^2)^2)^2)

I just didn't know if there might be more efficient (easier/faster) ways to do it since the exponent is a special number.
jfollas is offline   Reply With Quote
Old 2004-07-02, 17:09   #2
dave_dm
 
May 2004

8010 Posts
Default

Well I suppose it depends what you mean by 'mersenne'. If you mean 'mersenne prime' then yes, there is a shortcut.

Suppose we want to compute a^(2^b) mod (2^c-1), where 2^c-1 is prime and b>0. The group of units modulo 2^c-1 is cyclic of order 2^c-2, so it's enough to compute a^(2^b mod 2^c-2) mod (2^c-1).

But the binary representation of 2^b mod 2^c-2 is a single set bit and is equal to 2^(1 + (b-1) mod (c-1)),

i.e. the shortcut is to calculate a^(2^(1 + ((b-1) mod (c-1)))) mod (2^c-1).

However, if 2^c-1 is not prime then I can't see any (specific) speedups.

Dave
dave_dm is offline   Reply With Quote
Old 2004-07-02, 22:01   #3
jfollas
 
Jul 2004

E16 Posts
Default

By Mersenne, I simply meant any number in the form of 2^P-1, be it a prime or composite (though primality not necessarily known at the evaluation time).
jfollas is offline   Reply With Quote
Old 2004-07-02, 22:26   #4
jfollas
 
Jul 2004

2·7 Posts
Default

Hmm, it seems that your explaination works great for the case where the modulus is less than the exponent as in the example 37^1024 (mod 127). Thanks for the details, since I haven't seen that before.

But when the modulus is greater than the exponent, then there's no reduction that takes place.

65^2048 (mod 8191)

a=65, b=11, c=13

a^(2^(1 + ((b-1) mod (c-1)))) mod (2^c-1)
=65^(2^(1 + ((11-1) mod (13-1)))) mod (2^13-1)
=65^(2^(11 mod 12)) mod 8191
=65^2048 mod 8191
jfollas is offline   Reply With Quote
Reply

Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
TDP as power used? CRGreathouse Hardware 9 2016-02-06 18:46
prime power Sierpinski numbers snorton Prime Sierpinski Project 1 2015-03-25 03:07
The Chinese should be thanked for raising the bar... chalsall Science & Technology 4 2013-12-16 03:43
IBM Power 6 Unregistered Information & Answers 7 2008-08-30 14:36
Now power consumption numbers using Prime95 Dresdenboy Hardware 1 2004-11-23 18:29

All times are UTC. The time now is 15:08.


Mon Aug 2 15:08:19 UTC 2021 up 10 days, 9:37, 0 users, load averages: 2.62, 2.95, 3.18

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.

This forum has received and complied with 0 (zero) government requests for information.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation.
A copy of the license is included in the FAQ.