topic
description
Zhang Wuji that day saying inadvertently look at a "world problem solving Mathematical Olympiad Dictionary - Number Theory Volume" and see the solution of the greatest common divisor and least common multiple, deep internal strength he instantly found a correlation between the two, and now he comes test your product to calculate the greatest common divisor and least common multiple of two numbers, you can test it?
Entry
A number of row two and b, a and b 64 to ensure that the subject bit integer in
Export
And the greatest common divisor of two numbers of the least common multiple of the product, the title 64 ensure the output in the range of integers.
Sample input
2 6
Sample Output
12
prompt
2 and 6 is the least common multiple of 6, the common denominator is 2 so the answer is 12.
Ideas:
The least common multiple Guho:
= The product of the least common multiple of two numbers / the greatest common divisor
Greatest common divisor Seeking:
- A B Integer integer rounding, the remainder is represented by an integer from Example C: C = A% B
- If C is equal to 0, then C is an integer common divisor of A and the integer B
- If C is not equal to 0, B assigned to the A, B will be assigned to C, and then 1, 2-step, until the remainder is 0, it is possible that the greatest common divisor
def fun(num1, num2):
if num1 < num2:
num1, num2 = num2, num1
vari1 = num1 * num2
vari2 = num1 % num2
while vari2 != 0:
num1 = num2
num2 = vari2
vari2 = num1 % num2
vari1 /= num2
print(int(num2*vari1))
l=[int(x) for x in input().split()]
fun(l[0], l[1])