summaryrefslogtreecommitdiff
path: root/AlgoDesignAndTechniqueEdxPython/sources/gcdlcm.py
blob: 57b48fff5702a927669cdd1d934b5cdd694a08d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# Uses python3
import sys


def getGCD(a, b):
	if b == 0:
			return a
	if b > a:
		return getGCD(b, a)
	else:
		return getGCD(b, a % b)

def getLCM(a, b):
# 	https://www.idomaths.com/hcflcm.php#formula
	return a * b // getGCD(a, b)

if __name__ == '__main__':
    entryNumbers = sys.stdin.read()
    tokens = entryNumbers.split()
    a = int(tokens[0])
    b = int(tokens[1])
    print(getLCM(a, b))