Ruby Integer remainder() function with example
Last Updated :
03 Dec, 2020
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
num1 = 18
num2 = 3
num3 = 13
num4 = 5
puts num1.remainder(num2)
puts num3.remainder(num4)
|
Output:
0
3
Example 2:
Ruby
num1 = 19
num2 = 4
num3 = 20
num4 = 5
puts num1.remainder(num2)
puts num3.remainder(num4)
|
Output:
3
0
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...