Finding the HCF by Using a Method

Learn to find the HCF of two numbers using methods in Ruby.

We'll cover the following

Problem

Write a program that asks the user to enter two non-negative integers and then finds the highest common factor (HCF). The program must define a method that returns the divisors of a number.

Get hands-on with 1400+ tech skills courses.