mersenneforum.org

mersenneforum.org (https://www.mersenneforum.org/index.php)
-   Software (https://www.mersenneforum.org/forumdisplay.php?f=10)
-   -   New way to Find (X^Y) % M (https://www.mersenneforum.org/showthread.php?t=2446)

maheshexp 2004-05-08 02:50

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 2004-05-08 02:53

note r1 is the result of the function

ColdFury 2004-05-08 03:16

Look at my reply in the math section....


All times are UTC. The time now is 00:36.

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