How to find the Minimum of Three Numbers in Ruby - Step by Step Examples
How to find the Minimum of Three Numbers in Ruby ?
Answer
To find the minimum of three numbers in Ruby, you can use the `min` method.
✐ Examples
1 Find Minimum of Three Numbers
In this example,
- We declare an array with the numbers to compare.
- We use the `min` method on the array to get the minimum.
Ruby Program
nums = [5, 8, 3]
min_val = nums.min
puts "Minimum of three numbers is: #{min_val}"
Output
Minimum of three numbers is: 3
Summary
In this tutorial, we learned How to find the Minimum of Three Numbers in Ruby language with well detailed examples.