'''
求最大公约数(1):暴力枚举法,从较小整数的一半开始,试图找到一个合适的整数,
看看这个整数能否被a和b同时整除
'''
def getGreatestCommonDivisor(a,b):
big=0
small=0
if(a>b):
big=a
small=b
else:
big=b
small=a
if(big%small==0):
print(small)
for i in range(int(small/2),1,-1):
if(small%i==0 and big %i==0):
print(i)
getGreatestCommonDivisor(27,6)
08-12
736
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交