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

2510 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

5008 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 21:57.


Sat Oct 23 21:57:35 UTC 2021 up 92 days, 16:26, 0 users, load averages: 1.25, 1.22, 1.16

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.