Recursion: Array Sum

Published by rubens in

Write a function that finds the sum of a list. Make your function recursive.

Examples

sum_recursively([1, 2, 3, 4]) ➞ 10

sum_recursively([1, 2]) ➞ 3

sum_recursively([1]) ➞ 1

sum_recursively([]) ➞ 0

Notes

  • Return 0 for an empty list.
  • Check the Resources tab for info on recursion.
Watch a quick demo on how Edabit works.