Robotics & Artificial Intelligence
Write a Python program to input two numbers and find their HCF and LCM.
Python Control Flow
1 Like
Answer
a = int(input("Enter first number: "))
b = int(input("Enter second number: "))
x = a
y = b
while b != 0:
r = a % b
a = b
b = r
hcf = a
lcm = (x * y) // hcf
print("HCF:", hcf)
print("LCM:", lcm)Output
Enter first number: 12
Enter second number: 18
HCF: 6
LCM: 36
Answered By
3 Likes
Related Questions
Draw the circuit diagram and write the truth table for the NOR gate.
Write a function that returns the sum of multiples of 3 and 5 between 0 and limit (parameter). For example, if the limit is 20, it should return the sum of 3, 5, 6, 9, 10, 12, 15, 18, 20.
"Robots are flexible mechanical machines." Justify this statement.
"All robots are machines, but all machines are not robots." Prepare a write-up on the same.