在python官网(https://legacy.python.org/doc/essays/ppt/)翻到的关于最大公约数的编程:
def gcd(a, b):
“greatest common divisor”
while a != 0:
a, b = b%a, a # parallel assignment
return b
简洁得惊呆了,还是自己数学太差了,呜呜呜,还验证了很久~~
在python官网(https://legacy.python.org/doc/essays/ppt/)翻到的关于最大公约数的编程:
def gcd(a, b):
“greatest common divisor”
while a != 0:
a, b = b%a, a # parallel assignment
return b
简洁得惊呆了,还是自己数学太差了,呜呜呜,还验证了很久~~