Ruby Integer lcm() function with example Last Updated : 07 Jan, 2020 Comments Improve Suggest changes Like Article Like Report The lcm() function in Ruby returns the lcm of two numbers. LCM signifies the lowest common multiple which is divisible by both the numbers. Syntax: number1.lcm(number2) Parameter: The function requires two numbers whose lcm is returned. Return Value: The function returns the lcm of two numbers Example #1: Ruby # Ruby program of Integer lcm() function # Initializing the numbers num1 = 10 num2 = 15 num3 = 21 num4 = 14 # Prints the lcm value puts num1.lcm(num2) puts num3.lcm(num4) Output: 30 42 Example #2: CPP # Ruby program of Integer lcm() function # Initializing the numbers num1 = 22 num2 = 18 num3 = 30 num4 = 25 # Prints the lcm value puts num1.lcm(num2) puts num3.lcm(num4) Output: 198 150 Comment More infoAdvertise with us Next Article Ruby Integer lcm() function with example gopaldave Follow Improve Article Tags : Ruby Ruby-Methods Ruby Integer-class Similar Reads Ruby Integer to_r function with example The to_r function in Ruby converts the value of the number to a rational. Syntax: number.to_r Parameter: The function takes the number which is to be converted to a rational number. Return Value: The function returns the rational number. Example #1: Ruby # Ruby program for to_r function # Initializi 1 min read Ruby Integer modulo() function with example The modulo function in Ruby returns the modulo value of a number by another number. Syntax: number1.modulo(number2) Parameter: The function takes number1 and number2 whose modulo is returned. Return Value: The function returns the modulo value of a number by another number. Example #1: Ruby # Rub 1 min read Ruby Integer gcd() function with example The gcd() function in Ruby returns the gcd of two numbers. GCD signifies the greatest common divisor which divides both the numbers. Syntax: number1.gcd(number2) Parameter: The function requires two numbers whose gcd is to be returned. Return Value: The function returns the gcd of two numbers Exampl 1 min read Ruby Integer div() function with example The div() function in Ruby returns the integer division of two numbers. Syntax: (number1).div(number2) Parameter: The function needs two numbers number1 and number2, where number1 is the dividend and number2 is the divisor. Return Value: The function returns the integer division of two numbers. Exam 1 min read Ruby Integer chr function with example The chr function in Ruby returns the string containing the character represented by the int's value according to encoding. Syntax: string.chr([encoding]) Parameter: The function takes the integer value whose encoding is to be done. It takes a non-mandatory parameter encoding if encoding is to be don 1 min read Like