Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
recursion2.rb
list = [1, 2, 3, 4, 5, 6, 7]
def length(list)
if list.size == 0
0
else
list.shift
1 + length(list)
end
end
puts length(list)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment