mirror of
https://github.com/github/codeql.git
synced 2025-12-23 12:16:33 +01:00
24 lines
402 B
Python
24 lines
402 B
Python
|
|
#Written in Java or C style
|
|
def gcd(a, b):
|
|
while(a != 0 and b != 0):
|
|
if(a > b):
|
|
a = a % b
|
|
else:
|
|
b = b % a
|
|
if(a == 0):
|
|
return (b)
|
|
return (a)
|
|
|
|
#Written in a more Pythonic style
|
|
def gcd(a, b):
|
|
while a != 0 and b != 0:
|
|
if a > b:
|
|
a = a % b
|
|
else:
|
|
b = b % a
|
|
if a == 0:
|
|
return b
|
|
return a
|
|
|