Extended Euclidean Algorithm Function
A function for finding the modular multiplicative inverse, based on an extended version of the Euclidean algorithm.
|
On Friday, October 3rd 2008 at 09:12 AM By Andrew Pociu (View Profile)
    (Rated 0 with 0 votes) |
Contextual Ads
More Ruby Resources
Advertisement
def EGCD(b,m,recLevel=0)
if b % m == 0
tmpVal = [0,1]
return tmpVal
else
tmpVal = EGCD(m, b % m, recLevel+1)
tmpVal2 = [tmpVal[1], tmpVal[0]-tmpVal[1] * ((b/m).to_i)]
if recLevel == 0
return tmpVal2[0] % m
else
return tmpVal2
end
end
end
|
Digg It!
Del.icio.us
Reddit
StumbleIt
Newsvine
Furl
BlinkList
|
|
Rate this code snippet
Current Comments
There are no comments.
|
Related Source Code
There is no related code.
Related Tutorials
There are no related tutorials.
Ruby Job Search
|