Ruby Program to Find the Gcd Using Library Function

You are currently viewing Ruby Program to Find the Gcd Using Library Function

Ruby program to find the GCD using library function

# Ruby program to find the 
# GCD using library function

print "Enter number1: ";
num1 = gets.chomp.to_i;  

print "Enter number2: ";
num2 = gets.chomp.to_i;  

result = num1.gcd(num2);

print "Greatest Common Divisor: ",result;
Enter number1: 12
Enter number2: 16
Greatest Common Divisor: 4

Ranjith Kumar

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Reply