Implement recursive `sum` function