This problem requires the greatest common divisor and the least common multiple of two given positive integers . Input format :
Enter positive integers in each of the two lines x and y.
Output format :
Output the values of the maximum common divisor and the minimum common multiple in one line .
sample input 1: Here's a set of inputs . for example :
100
1520
sample output 1:
Here is the corresponding output .
for example :
20 7600
The following program realizes this function :
def hcf(x, y):
if x > y:
smaller = y
else:
smaller = x
for i in range(1,smaller + 1):
if((x % i == 0) and (y % i == 0)):
hcf = i
return hcf
def lcm(x, y):
if x > y:
greater = x
else:
greater = y
while(True):
if((greater % x == 0) and (greater % y == 0)):
lcm = greater
break
greater += 1
return lcm
num1 = int(input(" Enter the first number : "))
num2 = int(input(" Enter the second number : "))
print(" The greatest common divisor is ",hcf(num1, num2)," The least common multiple is ",lcm(num1,num2))