clear; clc;

data = randi(100, 1, 5);
s = 0;
for item = data
    s = s + item;
end
s
mySum(data)

function y = mySum(A)
    if length(A) > 1
        y = A(1) + mySum(A(2 : end));
    else
        y = A(1);
    end 
end