krujeen / python

0 stars 0 forks source link

ห.ร.ม.ของเลขจำนวนเต็มบวก 2 จำนวน #3

Open krujeen opened 3 years ago

krujeen commented 3 years ago

จงหา ห.ร.ม.ของเลขจำนวนเต็มบวก 2 จำนวน

โดย ข้อมูลนำเข้า เป็นตัวเลขสองจำนวน ข้อมูลออก เป็น ห.ร.ม. ของตัวเลขสองจำนวนนั้น

ตัวอย่างการทำงาน 1 input

18
24

output

6

ตัวอย่างการทำงาน 2 input

48
180

output

12
krujeen commented 3 years ago
import math
a = int(input())
b = int(input())
if (b>a) :
    c = b
    b = a
    a = c
while(a%b!=0):
    c = a%b
    a = b
    b = c
print(b)