Ruby Integer odd? function with example Last Updated : 07 Jan, 2020 Comments Improve Suggest changes Like Article Like Report The odd? function in Ruby returns a boolean value. It returns true if the number is odd, else it returns false. Syntax: number.odd? Parameter: The function takes the integer which is to be checked for odd or not. Return Value: The function returns a boolean value which determines if the value is odd or not. Example #1: Ruby # Ruby program of integer odd? function # Initializing the numbers num1 = 19 num2 = 2 num3 = 28 num4 = 13 # Prints true if number is odd puts num1.odd? puts num2.odd? puts num3.odd? puts num4.odd? Output: true false false true Example #2: Ruby # Ruby program of integer odd? function # Initializing the numbers num1 = 18 num2 = 200 num3 = 2987 num4 = 13 # Prints true if number is odd puts num1.odd? puts num2.odd? puts num3.odd? puts num4.odd? Output: false false true true Comment More infoAdvertise with us Next Article Ruby Integer odd? function with example gopaldave Follow Improve Article Tags : Ruby Ruby-Methods Ruby Integer-class Similar Reads 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 pred() function with example The pred function in Ruby returns the immediate predecessor of the number, i.e., it returns number - 1. If a float value is used, it throws an error message. Syntax: number.pred Parameter: The function takes the integer whose predecessor is to be returned. Return Value: The function returns the imme 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 next function with example The next function in Ruby returns the immediate successor of the number, i.e., it returns number + 1. If a float value is used, it throws an error message. Syntax: number.next Parameter: The function takes the integer whose next is to be returned. Return Value: The function returns the immediate suc 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 prime? function with example The prime? function in Ruby returns a boolean value. It returns true if the number is prime, else it returns false. It requires the 'prime' class to be pre-added. Syntax: number.prime? Parameter: The function takes the integer which is to be checked for prime or not. Return Value: The function ret 1 min read Ruby Integer abs() function with example The abs() function in Ruby returns the absolute value of the integer. Syntax: (number).abs Parameter: The function takes the integer whose absolute value is to be returned. Return Value: The function returns the absolute value of the integer. Example #1: Ruby # Ruby program Integer abs() function # 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 even? function with example The even? function in Ruby returns a boolean value. It returns true if the number is even, else it returns false. Syntax: number.even? Parameter: The function takes the integer which is to be checked for even or not. Return Value: The function returns a boolean value which determines if the value is 1 min read Like