Recursive sum function

Array recursive sum problem

Given an array of N integers. Write a recursive function to calculate the sum of all elements in the array.

Recursive sum function

Recursive sum algorithm

The sum of N elements in a list is equivalent to the sum of one element of the array and the rest N-1 elements

Code

The following is a suggested solution in PHP.

Add a Comment

Your email address will not be published. Required fields are marked *