function S = sumCubes(v)
% takes a vector as input and returns the sum
% of the cubes of its elements.

    % Method 1: a straightforward method
    S = 0; 
    for i = 1:length(v)
        S = S + v(i)^3; 
    end

    % Method 2: valid, but not recommended
    %S = 0;
    %for x = v
    %    S = S + x^3;
    %end

    % Method 3: a natural way to write it in Matlab
    %S = sum(v.^3); 
    
end