Recursion exercises in Ruby and Javascript