Finding the Highest Common Factor
Learn to find the highest common factor for two numbers in Ruby.
Problem
Write a program that asks the user to enter two non-negative integers and find their highest common factor (HCF).
Enter the first number: (8)Enter the second number: (12)The HCF of 8 and 12 is: 4
Calculating HCF of two numbers
The largest common factor of two or more numbers is called the highest common factor. The HCF is also known as the greatest common divisor (GCD).
For example,
...