Created
June 22, 2016 10:42
-
-
Save tomcha/2de8f0a55679fd16b2f181f52a51b894 to your computer and use it in GitHub Desktop.
recursion4.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
list = [5, 8, 2, 3] | |
def min(list) | |
if list.size == 1 | |
list.shift | |
else | |
i = list.shift | |
list[0] = i if i < list[0] | |
min(list) | |
end | |
end | |
puts min(list) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment