Ruby | Numeric remainder() function
Last Updated :
19 Mar, 2024
The remainder() is an inbuilt method in Ruby returns the remainder when num1 is divided by num2.
Syntax: num1.remainder(num2)
Parameters: The function needs num1 and num2 which are to be divided.
Return Value: It returns the remainder.
Example 1:
num1 = 17
num2 = 4
puts num1.remainder(num2)
|
Output:
1
Example 2:
num1 = 12
num2 = 5
puts num1.remainder(num2)
|
Output:
2
Share your thoughts in the comments
Please Login to comment...