Ruby Integer modulo() function with example
The modulo function in Ruby returns the modulo value of a number by another number.
Syntax: number1.modulo(number2)
Parameter: The function takes number1 and number2 whose modulo is returned.
Return Value: The function returns the modulo value of a number by another number.
Example #1:
Ruby
num1 = 10
num2 = 6
num3 = 13
num4 = 5
puts num1.modulo(num2)
puts num3.modulo(num4)
|
Output:
4
3
Example #2:
Ruby
num1 = 100
num2 = 17
num3 = 90
num4 = 29
puts num1.modulo(num2)
puts num3.modulo(num4)
|
Output:
15
3
Last Updated :
03 Dec, 2020
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...