IN PYTHON:
Please answer as simply as possible in Python
The highest Common Factor of a pair of numbers is the largest number than will divide evenly into both members of the pair. Write a program to read in two numbers and compute the Highest Common Factor.
The output will look like this:
Enter the first number: 4
Enter the second number: 20
The highest common factor: 4
Python code:
#accepting first number
num1=int(input("Enter the first number: "))
#accepting second number
num2=int(input("Enter the second number: "))
#iniitalizing highest common factor as 1
high=1
#looping from 1 to num2
for i in range(1,num2):
#checking if i is divisible by both
numbers
if(num1%i==0 and num2%i==0):
#assigning i to
high
high=i
#printing highest common factor
print("The highest common factor:",high)
Screenshot:
Input and Output:
Get Answers For Free
Most questions answered within 1 hours.