Skip to content

Commit

Permalink
Added Pollard's Rho in Python
Browse files Browse the repository at this point in the history
  • Loading branch information
jcla1 committed Jun 28, 2014
1 parent c6d5b69 commit e5a3058
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Pollard_Rho_Algorithm/Python/jcla1/pollard.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
def pollard(n, f):
x, y, d = 2, 2, 1
while d == 1:
x = f(x, n)
y = f(f(x, n), n)
d = gcd(abs(x - y), n)

if d == n: return -1
return d

def gcd(a, b):
if (b == 0): return a
return gcd(b, a % b)

0 comments on commit e5a3058

Please sign in to comment.