PROJECT-12

HCF and LCM Finder

''' HCF Finder '''
num1 = int(input("Enter first number : "))   # num1 small
num2 = int(input("Enter second number : "))# num 2 great
hcf=1
real1=num1
real2=num2
if num1<num2:
	while num1!=0:
		hcf=num1
		a=num2%num1
		num2=num1
	#	print(num1)
		num1=a
	print(f"HCF of {real1} and {real2} is {hcf}")
	#break
else:
	while num2!=0:
		hcf=num2
		a=num1%num2
		num1=num1
	#	print(num1)
		num2=a
	print(f"HCF of {real1} and {real2} is {hcf}")
	#break
''' LCM Finder '''
#real1 * real2 = lcm * hcf 
# so, lcm= (real1 * real2)/hcf
lcm= int((real1 * real2)/hcf)
print(f"LCM of {real1} and {real2} is {lcm}")

Design a site like this with WordPress.com
Get started