From d5304cabd515190b5e2b812ce8b838ebf735fcf5 Mon Sep 17 00:00:00 2001 From: Michael Manganiello Date: Wed, 20 Jan 2016 20:29:48 -0300 Subject: Simplified calculation of GCD --- rsa/prime.py | 6 +++--- 1 file 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 -- cgit v1.2.1