summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Manganiello <mike@fmanganiello.com.ar>2016-01-20 20:29:48 -0300
committerMichael Manganiello <mike@fmanganiello.com.ar>2016-01-20 20:29:48 -0300
commitd5304cabd515190b5e2b812ce8b838ebf735fcf5 (patch)
tree7b26b8f620dc22c41945ffd1d2ac3d0421ee439b
parent29d202d869e96e50637f9bb1a96703e169c560f7 (diff)
downloadrsa-d5304cabd515190b5e2b812ce8b838ebf735fcf5.tar.gz
Simplified calculation of GCD
-rw-r--r--rsa/prime.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/rsa/prime.py b/rsa/prime.py
index 7422eb1..2e23a2d 100644
--- a/rsa/prime.py
+++ b/rsa/prime.py
@@ -24,6 +24,7 @@ __all__ = [ 'getprime', 'are_relatively_prime']
import rsa.randnum
+
def gcd(p, q):
'''Returns the greatest common divisor of p and q
@@ -32,10 +33,9 @@ def gcd(p, q):
'''
while q != 0:
- if p < q: (p,q) = (q,p)
- (p,q) = (q, p % q)
+ (p, q) = (q, p % q)
return p
-
+
def jacobi(a, b):
'''Calculates the value of the Jacobi symbol (a/b) where both a and b are