Ruby | Numeric denominator() function
Last Updated :
19 Mar, 2024
The denominator() is an inbuilt method in Ruby returns the denominator of the number.
Syntax: num1.denominator()
Parameters: The function needs a number whose denominator is returned.
Return Value: It returns itself only.
Example 1:
# Ruby program for denominator() method in Matrix
# Initialize a number
num1 = 1.5
# Function used
num = num1.denominator()
# Prints denominator() of num
puts num
|
Output:
2
Example 2:
# Ruby program for denominator() method in Matrix
# Initialize a number
num1 = 155
# Function used
num = num1.denominator()
# Prints denominator() of num
puts num
|
Output:
1
Share your thoughts in the comments
Please Login to comment...