summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Manganiello <mike@fmanganiello.com.ar>2016-01-20 20:29:48 -0300
committerSybren A. Stüvel <sybren@stuvel.eu>2016-01-21 11:12:33 +0100
commitebfa910c6a17be5b1ace06ea10d1171ec9dae29a (patch)
tree7b26b8f620dc22c41945ffd1d2ac3d0421ee439b
parentf68c52a018721dfb536cc735a6bfee4a9af1c419 (diff)
downloadrsa-git-ebfa910c6a17be5b1ace06ea10d1171ec9dae29a.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