Ad
Code
Diff
  • def sum(arr):
        if not arr:
            return 0
        else:
            return arr[0] + sum(arr[1:])
        
    • def sum(arr):
    • result = 0
    • for i in arr:
    • result += i
    • return result
    • if not arr:
    • return 0
    • else:
    • return arr[0] + sum(arr[1:])