Skip to content

Instantly share code, notes, and snippets.

@tomcha
Created June 22, 2016 10:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomcha/2af889aabaf90bad8f4c70803b040a06 to your computer and use it in GitHub Desktop.
Save tomcha/2af889aabaf90bad8f4c70803b040a06 to your computer and use it in GitHub Desktop.
recursion3.rb
list = [5, 8, 2, 3]
def max(list)
if list.size == 1
list.shift
else
i = list.shift
list[0] = i if list[0] < i
max(list)
end
end
puts max(list)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment