Ruby Integer gcd() function with example Last Updated : 07 Jan, 2020 Comments Improve Suggest changes Like Article Like Report 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 Example #1: CPP # Ruby program of Integer gcd() function # Initializing the numbers num1 = 10 num2 = 15 num3 = 21 num4 = 14 # Prints the gcd value puts num1.gcd(num2) puts num3.gcd(num4) Output: 5 7 Example #2: Ruby # Ruby program of Integer gcd() function # Initializing the numbers num1 = 22 num2 = 18 num3 = 30 num4 = 25 # Prints the gcd value puts num1.gcd(num2) puts num3.gcd(num4) Output: 2 5 Comment More infoAdvertise with us Next Article Ruby Integer gcd() function with example gopaldave Follow Improve Article Tags : Ruby Ruby-Methods Ruby Integer-class Similar Reads Ruby Integer gcdlcm() function with example The gcdlcm() function in Ruby returns an array with the greatest common divisor and the least common multiple of the two integers. GCD signifies the greatest common divisor which divides both the numbers and lcm signifies the least common multiple of both the numbers Syntax: number1.gcdlcm(number2) 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 lcm() function with example 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 Examp 1 min read Ruby Integer fdiv() function with example The fdiv() function in Ruby returns the floating point result after division of two numbers. Syntax: (number1).fdiv(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 floating point 1 min read 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 floor() function with example The ceil function in Ruby returns the smallest number smaller than or equal to int with a precision of ndigits decimal digits. The default is considered to be 0. When the precision given is negative, the returned value is an integer with at least ndigits.abs trailing zeros. It returns self when ndig 1 min read Ruby Integer divmod() function with example The divmod() function in Ruby returns integer division value and the remainder. Syntax: (number1).divmod(number2) Parameter: The function takes two number number1 and number2 whose integer division and remainder is returned. Return Value: The function returns the integer division value and the remai 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 remainder() function with example The remainder() function in Ruby returns the remainder when two numbers are divided. Syntax: (number1).remainder(number2) Parameter: The function takes two number number1 and number2 whose integer division and remainder is returned. Return Value: The function returns the remainder. Example 1: Rub 1 min read Ruby | BigDecimal remainder() function BigDecimal#remainder() : remainder() is a BigDecimal class method which divides the two BigDecimal values and returns the remainder value. Syntax: BigDecimal.remainder() Parameter: BigDecimal values Return: divides the two BigDecimal values and returns the remainder value. Example #1 : Ruby # Ruby c 2 min read Like