Ruby Integer remainder() function with example Last Updated : 03 Dec, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report 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: Ruby # Ruby program for remainder() function # Initializing the numbers num1 = 18 num2 = 3 num3 = 13 num4 = 5 # Printing the modulo value puts num1.remainder(num2) puts num3.remainder(num4) Output: 0 3 Example 2: Ruby # Ruby program for remainder() function # Initializing the numbers num1 = 19 num2 = 4 num3 = 20 num4 = 5 # Printing the modulo value puts num1.remainder(num2) puts num3.remainder(num4) Output: 3 0 Comment More infoAdvertise with us Next Article Ruby Integer remainder() function with example G gopaldave Follow Improve Article Tags : Ruby Ruby-Methods Ruby Integer-class Similar Reads 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 magnitude function with example The magnitude() function in Ruby returns the absolute value of the integer. It is similar to the abs function and is an alias of it. Syntax: (number).magnitude Parameter: The function takes the integer whose magnitude is to be returned. Return Value: The function returns the absolute value of the in 1 min read Ruby Integer integer? function with example The integer? function in Ruby returns a boolean value. It returns true if the number is an int, else it returns false. Syntax: number.integer? Parameter: The function takes the integer which is to be checked for int or not. Return Value: The function returns a boolean value which determines if the v 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 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 Like