Ruby Program to Calculate the Logarithm of a Given Number Based on a Given Base

You are currently viewing Ruby Program to Calculate the Logarithm of a Given Number Based on a Given Base

Ruby program to calculate the logarithm of a given number based on a given base

# Ruby program to calculate the logarithm 
# of a given number based on a given base

print "Enter Number: ";
num = gets.chomp.to_i;  

print "Enter Base: ";
base = gets.chomp.to_i;  


result = Math.log(num,base);

print "Result is: ",result;
Enter Number: 124
Enter Base: 2
Result is: 6.954196310386876

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