Ruby | Integer % method
Last Updated :
18 Dec, 2019
The % is an inbuilt method in Ruby returns the remainder after the integer division of two numbers. It returns num1 % num2.
Syntax: num1 % num2
Parameters: The function accepts no parameter.
Return Value: It returns the remainder after the integer division of two numbers.
Example 1:
num1 = 15
num2 = 4
print num1 % num2
|
Output:
3
Example 2:
num1 = 21
num2 = 3
print num1 % num2
|
Output:
0
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...