Skip to content

Commit ebfa910

Browse files
adamantikesybrenstuvel
authored andcommitted
Simplified calculation of GCD
1 parent f68c52a commit ebfa910

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

rsa/prime.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
import rsa.randnum
2626

27+
2728
def gcd(p, q):
2829
'''Returns the greatest common divisor of p and q
2930
@@ -32,10 +33,9 @@ def gcd(p, q):
3233
'''
3334

3435
while q != 0:
35-
if p < q: (p,q) = (q,p)
36-
(p,q) = (q, p % q)
36+
(p, q) = (q, p % q)
3737
return p
38-
38+
3939

4040
def jacobi(a, b):
4141
'''Calculates the value of the Jacobi symbol (a/b) where both a and b are

0 commit comments

Comments
 (0)