All problems

Problem 71

Least Common Multiple

Easy · 10 pts · Math

Problem

You are given two positive integers A and B. Print their least common multiple (LCM): the smallest positive integer that both A and B divide exactly. The LCM and the greatest common divisor are linked by LCM(A, B) = A × B / GCD(A, B). To avoid overflow, divide first: compute A / GCD(A, B) × B. The result can be up to 10^18, so use a 64-bit integer.

Input

Two integers A and B separated by a space.

Output

Print LCM(A, B).

Constraints

1 <= A, B <= 1000000000 (the answer fits in a 64-bit integer)

Example input

4 6

Example output

12

Explanation

The multiples of 4 are 4, 8, 12, 16, ... and the multiples of 6 are 6, 12, 18, ... The first number in both lists is 12. With the formula: GCD(4, 6) = 2, and 4 / 2 × 6 = 12.

Every problem here can be used in a RelayTrixCode team match. Create a room.

Previous: Word Pattern Next: Sum of Digits