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:
# Ruby program for remainder() # method in Numeric # Initialize a number num1 = 17num2 = 4 # Prints the remainder part puts num1.remainder(num2) |
chevron_right
filter_none
Output:
1
Example 2:
# Ruby program for remainder() # method in Numeric # Initialize a number num1 = 12num2 = 5 # Prints the remainder part puts num1.remainder(num2) |
chevron_right
filter_none
Output:
2
Recommended Posts:
- Ruby Integer remainder() function with example
- Ruby | BigDecimal remainder() function
- Ruby | Numeric imaginary() function
- Ruby | Numeric i() function
- Ruby | Numeric fdiv() function
- Ruby | Numeric zero? function
- Ruby | Numeric floor() function
- Ruby | Numeric phase() function
- Ruby | Numeric finite?() function
- Ruby | Numeric real? function
- Ruby | Numeric divmod() function
- Ruby | Numeric div() function
- Ruby | Numeric denominator() function
- Ruby | Numeric conjugate() function
- Ruby | Numeric conj() function
- Ruby | Numeric coerce() function
- Ruby | Numeric arg() function
- Ruby | Numeric angle() function
- Ruby | Numeric abs2() function
- Ruby | Numeric magnitude() function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

