给定两个整数a,b,求他们的最大公约数

def gcd(a,b):
    if a<b:
        a,b=b,a
    while(a%b != 0):
        c = a%b
        a=b
        b=c
    return b

a,b = map(int,input("请输入两个整数:").split()) #一次输入两个变量的方式
res = gcd(a,b)
print(res)

  

def gcd(a,b):
    if a%b == 0:
        return b
    else :
        gcd(b,a%b)

a,b = map(int,input("请输入两个整数:").split())
c = gcd(a,b)
print(c)

  

相关文章:

  • 2021-12-04
  • 2021-06-08
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-10
  • 2021-06-21
猜你喜欢
  • 2022-12-23
  • 2021-10-02
  • 2021-06-03
相关资源
相似解决方案