mersenneforum.org  

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

Reply
 
Thread Tools
Old 2004-05-08, 02:50   #1
maheshexp
 
May 2004

52 Posts
Lightbulb New way to Find (X^Y) % M

here i had developed a simple algorithm to calculate (X^Y)%M. i works well and faster than any string manipulated operations.

//(x^y)%m
long r1 = x % m;
// loop upto y - 1, for x ^(y-1)
for (long i = 0; i < y - 1; i++) {
r1 = (r1 * x) % m;
}


hope this works...

mahesh
maheshexp is offline   Reply With Quote
Old 2004-05-08, 02:53   #2
maheshexp
 
May 2004

52 Posts
Default

note r1 is the result of the function
maheshexp is offline   Reply With Quote
Old 2004-05-08, 03:16   #3
ColdFury
 
ColdFury's Avatar
 
Aug 2002

26×5 Posts
Default

Look at my reply in the math section....
ColdFury is offline   Reply With Quote
Reply

Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
Where can I find a Reverse and Add program? I can't find any! Stargate38 Programming 18 2015-07-10 06:08
Help Find a Sequence? davar55 Math 2 2010-02-19 16:54
Find the Value davar55 Puzzles 7 2009-07-02 19:46
Find the Value davar55 Puzzles 25 2007-07-15 15:56
New way to Find (X^Y) % M maheshexp Miscellaneous Math 29 2004-08-30 15:59

All times are UTC. The time now is 04:39.

Tue Aug 11 04:39:22 UTC 2020 up 25 days, 26 mins, 1 user, load averages: 2.77, 2.92, 2.69

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, 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.