ง่าย 0 ข้อที่แก้แล้ว อัตราผ่าน 0%

Least Common Multiple

Find the smallest positive number divisible by both values.

Return the least common multiple of a and b, the smallest positive number that both divide. lcm(a, b) = a / gcd(a, b) × b.

Implement lcm(a, b).

Input

a: The first positive number. b: The second positive number.

Output

Return lcm(a, b).

เงื่อนไข

1 ≤ a, b ≤ 1,000,000,000

ตัวอย่าง

ตัวอย่างที่ 1
อินพุต:
a = 4
b = 6

ผลลัพธ์ที่คาดหวัง:
expected = 12
อินพุต:
long long a = 4;
long long b = 6;

ผลลัพธ์ที่คาดหวัง:
long long expected = 12;
อินพุต:
long a = 4;
long b = 6;

ผลลัพธ์ที่คาดหวัง:
long expected = 12;

คำอธิบาย

Multiples of 4: 4, 8, 12…; multiples of 6: 6, 12…; the first common one is 12.

ตัวอย่างที่ 2
อินพุต:
a = 7
b = 7

ผลลัพธ์ที่คาดหวัง:
expected = 7
อินพุต:
long long a = 7;
long long b = 7;

ผลลัพธ์ที่คาดหวัง:
long long expected = 7;
อินพุต:
long a = 7;
long b = 7;

ผลลัพธ์ที่คาดหวัง:
long expected = 7;

คำอธิบาย

A number's LCM with itself is the number: 7.

แหล่งอ้างอิง

โจทย์นี้ปรับให้เหมาะกับ CodeUtility กรุณาทำตามคำชี้แจงและข้อจำกัดด้านบน

เรียนรู้จากคนอื่น

แนวทางจากชุมชน

ยังไม่มีวิธีทำที่เผยแพร่ ลองแก้โจทย์นี้เพื่อแชร์วิธีแรก