#29468: 為甚麼會過不了?


511254@stu.tnssh.tn.edu.tw (YU-CHENG HOU)


a,b=map(int,input().split(' '))

GCD=1 

i=1

while i<=a and i<=b:

    if a%i==0 and b%i==0:

        GCD=i

    i+=1

print(GCD)

#29469: Re:為甚麼會過不了?


cges30901 (cges30901)


a,b=map(int,input().split(' '))

GCD=1 

i=1

while i<=a and i<=b:

    if a%i==0 and b%i==0:

        GCD=i

    i+=1

print(GCD)


用輾轉相除法